Linux process view command

  

The commands for viewing processes under Linux are: ps, pstree, top.

1. The psps command is used to view the current process.

General format: ps [options]

Common options: -a : Display information about all processes related to tty (except session leader) in the system. -e : Display information about all processes. -f : Display process information in a tree format. -j : Display process information in working format. -l : Display process information in long format. -r : Show only the processes that are running. -u : Display user-oriented format (including information such as user name, CPU, and memory usage). -x : Displays process information on all terminals. Common commands: 1) Display the progress of the current console.

ps

PID TTY TIME CMD28320 pts/0 00:00:00 bash28441 pts/0 00:00:00 ps

2)Display all processes in the system.

ps -e

3) Display details of all user processes.

ps aux

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMANDroot 1 0.0 0.2 2156 668 ? Ss Sep23 0:04 init [3]root 1114 0.0 0.2 2260 552 ? S< ;s Sep23 0:00 /sbin/udevd -droot 1193 0.0 0.2 32696 564 ? Ssl Sep23 0:00 brcm_iscsiuioroot 1386 0.0 0.2 1812 616 ? Ss Sep23 0:00 syslogd -m 0root 1441 0.0 0.4 7204 1064 ? Ss Sep23 0:00 /usr/sbin/sshdroot 1452 0.0 0.3 2832 832 ? Ss Sep23 0:00 xinetd -stayalive -pidfile /var/run/xinetd.pid......root 28318 0.0 1.1 10196 2892 ? Ss 19:38 0:00 Sshd: root@pts/0root 28320 0.0 0.5 3716 1516 pts/0 Ss 19:38 0:00 -bashroot 28444 0.0 0.3 2532 908 pts/0 R+ 20:44 0:00 ps aux

Information :USER The user who started the process. PID process ID number. %CPU The ratio of the CPU's time spent running the process to the total running time of the process. %MEM The process occupies the ratio of memory to total memory. The size of VSZ virtual memory, in KB. unit. The amount of real memory used by RSS, in kilobytes. TTY The terminal corresponding to the process establishment, “? ” indicates that the process does not occupy the terminal. The running state of the STAT process, including the following code: D Uninterruptible sleep. R Execution. S sleep. T Track or stop. Z terminates. W has no memory resident page. < High priority process. N Low priority process. L has pages locked into memory (for real-time tasks or UO tasks). The time when START starts running.

4) View the memory size occupied by a program (take httpd as an example)

ps -C httpd v

PID TTY STAT TIME MAJFL TRS DRS RSS %MEM COMMAND5511 ? Ss 0:50 114 325 51374 9692 3.9 /usr/sbin/httpd7274 ? S 0:03 0 325 53242 20244 8.1 /usr/sbin/httpd7328 ? S 0:00 0 325 53214 18572 7.4 /usr/sbin/httpd7349 ? S 0:00 0 325 53214 18376 7.3 /usr/sbin/httpd7364 ? S 0:00 0 325 53214 18344 7.3 /usr/sbin/httpd

2, the pstreepstree command displays the process in a tree structure. Shows the interrelationship between processes.

General format: pstree [options]

Common options: -a : Display the complete command of the process. -A : Display using ASCII characters. -u : Display the username. -p : Displays the program PID.

Common Commands:

pstree -Aup

3. The toptop command dynamically displays the current task status of the system, which is equivalent to the task manager.

General format: top [options]

Common options: -b : Use batch mode, do not accept command line input. -c : Display complete information about each process. -d <interval seconds> Sets the interval between refreshes. -i: Ignore idle and zombie processes. -n <executions> : Set the number of updates. -s : Runs in safe mode, disables some mutual commands. -S : Cumulative mode, which outputs the total CPU time of each process, including the dead child process.

There is also an interactive command during top execution: space is updated immediately. c Switch to the command name display or display the entire command (including parameters). f, F Increase the display field, or delete the display field. h,? Displays help information about the security mode and accumulation mode. k Prompts for the process ID to kill, in order to kill the process (default signal is 15). i Disable idle processes and zombie processes. l Switch to information such as the average of the simulated load and the time of normal operation. m Switches to memory information and sorts by memory footprint. n The number of processes displayed by the prompt, such as input 3, displays 3 processes on the entire screen. o, O changes the order in which the fields are displayed. r Apply renice to a process, prompting for the values ​​of PID and renice. s Change the refresh interval twice, in seconds. t Switches to the information showing the process and CPU status. A is sorted by process life size, and the latest process is displayed first. M is sorted by memory footprint, from large to small. N is sorted by process ID size, from large to small. P Sort by CPU usage, from large to small. S Switches to the cumulative time mode. T Sort tasks by time/accumulation time. W Write the current configuration to ~/.toprc.

Common commands: Just use top.

Copyright © Windows knowledge All Rights Reserved