Frequently used shell commands (updated in succession)

Source: Internet
Author: User
Tags date1 echo b

It's just my personal use, not all of it.


1. Get the return value in front of the pipeline

Echo ${pipestatus[0]}

e.g.

[Email protected]:~# date1 | echo 22No command ' date1 ' found, did your Mean:command ' date ' from the package ' coreutils ' (main) Date1:command not Found[emai L protected]:~# Echo ${pipestatus[0]}127

2. Review the Process

Ps-ef | grep Pidname | Grep-v grep

Note:-V is excluded,-EF is the parameter of PS

e.g.

[Email protected]:~# ps-ef | grep Ceph | Grep-v greproot     34880     1  0 11:14 pts/1    00:01:15/usr/bin/ceph-mon-i node1--pid-file/var/run/ceph/ Mon.node1.pid-c/etc/ceph/ceph.conf--cluster cephroot     37315     1  0 11:17?        00:00:38/usr/bin/ceph-osd-i 0--pid-file/var/run/ceph/osd.0.pid-c/etc/ceph/ceph.conf--cluster cephroot     37538< C9/>1  0 11:17?        00:00:36/usr/bin/ceph-osd-i 1--pid-file/var/run/ceph/osd.1.pid-c/etc/ceph/ceph.conf--cluster cephroot     46838     1  0 11:39?        00:00:02/usr/bin/ceph-mds-i node1--pid-file/var/run/ceph/mds.node1.pid-c/etc/ceph/ceph.conf--cluster ceph


3. Power off

echo B >/proc/sysrq-trigger


4. View the script after he runs, and go to the foreground to run

jobs: See all scripts running in the background
FG. : Run in front

Add a & behind the script, you can run in the background, even if Xshell accidentally shut down can continue to run, if you want to see in the background to run those, or turn off these processes, use the above two commands to the foreground


5. View memory usage and clean up memory

View memory usage free-m

Clear Memory
echo 3 >/proc/sys/vm/drop_caches release all memory that can be freed
0– not release
-Free Page Cache
Release Dentries and Inodes
3– Release All Caches

Simply put, clear the system to the memory cache, using root to do the following steps:
1. Sync
2. Echo 3 >/proc/sys/vm/drop_caches
3. Sync
4. echo 0 >/proc/sys/vm/drop_caches


6. Run the script in debug mode and save the results to a file

Sh-x/script_path > File 2>&1


7. Find out if all files in the directory contain a string

Find if all files in the directory contain a string
Find. | Xargs Grep-ri "string"
Finds all files in the directory that contain a string, and prints only the file name
Find. | Xargs Grep-ri "string"-l




Frequently used shell commands (updated in succession)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.