Summary of common commands for linux query process

01. Common commands for query process

01. ps basic commands

The ps command is used to list a snapshot of the process at the moment of execution, just like the phone took a photo of the process. If you want to display process information dynamically, you need to use the top command, which is like switching the phone mode to the video mode.

Unix style display all processes
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

BSD style display all processes

Insert picture description here
Insert picture description here
Insert picture description here
View the ranking list of CPU or memory consumption
Insert picture description here

AIX style display process
Insert picture description here
Insert picture description here
Insert picture description here

02. pstree display process tree

Insert picture description here
Insert picture description here

03. pgrep filtering process

Insert picture description here

04. kill to terminate the process

Insert picture description here
Insert picture description here

05. killall terminates the process by the process name

Insert picture description here
Insert picture description here
Note : You may not be able to kill it once, you need to execute it multiple times

06. pkill terminates the process by the process name

Insert picture description here
Note : pkill can kill processes and child processes

07. top process real-time monitoring

Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

08. nice adjust process priority

Process priority ranges from -20 (highest priority) to 19 (lowest priority). The program with the highest priority occupies the CPU more times, and vice versa.
Insert picture description here
Insert picture description here
Insert picture description here
Note : You can only modify the priority of the program that is not running when it is about to run.

09. renice adjusts the priority of running processes

In the system, sometimes it is found that a process that is not very important occupies too many cpu resources, so I hope to limit this process or hope that a process is executed first. (Includes adjustments to non-running processes)

Insert picture description here

10. Nohup user exits the system to continue working

nohup will ignore the signal that the process is suspended, and the output of the running process will not be displayed to the terminal. By default, it will be written to the nohup.out file in the current directory. If the current directory has insufficient permissions, the output will be redirected to the $HOME/nuhup.out file.

11. & background execution

& Will run the command in the background of the current window, free the current window to perform other operations. If the window is closed, the background process will interrupt execution.

Note : Generally nouhp is used in combination with &

12. Strace system calls to track the process

Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

13. ltrace traces the system functions called by the process

Insert picture description here

14. runlevel system run level

Insert picture description here

  • 0: stop
  • 1: Single user mode
  • 2: No network multi-user mode
  • 3: Multi-user mode
  • 4: The system is not used, keep it generally not used
  • 5: Graphical interface multi-user mode
  • 6: Restart

15. init initialize the linux process

  • init 0: shutdown
  • init 6: restart

16. service Management system services

Service+service name+command in CentOS 6

  • start: start
  • stop: stop
  • restart: restart
  • reload: load
  • status: view status

CentOS 7 was replaced by systemctl.

Insert picture description here

Guess you like

Origin blog.csdn.net/qq_42226855/article/details/112391144