Common shell commands (updated in succession)

Source: Internet
Author: User
Tags date1 echo b

Common shell commands (updated in succession)

1. Obtain the returned values before the MPs queue.

Echo $ {PIPESTATUS [0]}

E.g.

 

root@node2:~# date1 | echo 22No command 'date1' found, did you mean: Command 'date' from package 'coreutils' (main)date1: command not foundroot@node2:~# echo ${PIPESTATUS[0]}127

2. View Processes

 

Ps-ef | grep pidname | grep-v grep

Note:-v indicates exclusion, and-ef indicates ps parameter.

E.g.

 

root@node1:~# 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     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 Failure

Echo B>/proc/sysrq-trigger

4. Check the script that he runs and transfer it to the front-end for running.

Jobs: view all scripts running in the background
Fg 1/2...

The script can be run in the background by adding an &. Even if Xshell is accidentally shut down, it can continue to run. If you want to view the processes that are running in the background, or close these processes, run the preceding two commands to go to the front-end.


5. view memory usage and clear memory

View memory usage free-m

Clear memory
Echo 3>/proc/sys/vm/drop_caches release all available memory
0-do not release
1-release page Cache
2-release dentries and inodes
3-release all caches

Simply put, clear the system's memory cache and use root to perform 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 result to the file.

Sh-x/script_path> file 2> & 1

7. check whether all files in the directory contain a certain string.

Check whether all files in the directory contain a certain string
Find. | xargs grep-ri "string"
Check whether all files in the directory contain a certain string and print only the file name.
Find. | xargs grep-ri "string"-l

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.