Detailed analysis of Linux operating system PS commands

Source: Internet
Author: User
For detailed parsing of Linux operating system PS commands, you need to monitor and control the processes in the system, and use ps commands to meet your requirements. /Bin/psps displays the instantaneous travel status and is not dynamically consecutive. if you want to monitor the running time of the process, you should use the top tool. Kill is used to kill processes .... For detailed parsing of Linux operating system PS commands, you need to monitor and control the processes in the system, and use ps commands to meet your requirements. /Bin/psps displays the instantaneous travel status and is not dynamically consecutive. if you want to monitor the running time of the process, you should use the top tool. Kill is used to kill a process. ================== Ps parameter description ================================== ======= l long format output; u displays processes in the username and start time order; j displays processes in the task format; f displays processes in the tree format; a: displays all processes of all users (including other users); x displays processes without control terminals; r displays processes in progress; ww avoids detailed parameter truncation; -A: list all the Itineraries.-w: show widening: show more information.-au: show more detailed information.-aux: show all the itineraries containing other users.-e: show all processes, environment variable-f full format-h does not show title-l long format-w width output a shows all processes on the terminal, including other user processes, r only displays processes in the running state x shows processes in the non-controlling state. our common options are combination of aux or lax, and application of parameter f. O [+ |-] k1 [, [+ |-] k2 [,…] The process list is displayed in the multi-level sorting order specified by the shortcut KEYS in short keys, k1, and k2. the default sequence is specified for different ps formats. these default sequence can be overwritten by user-specified. here, the "+" character is optional, and the "-" character is used to reverse the specified key direction. pids lists only process identifiers separated by commas. the process list must be followed by the last option of the command line parameter. spaces cannot be inserted in the middle. for example, ps-f1, 4, 5. the following describes the long command line options. these options start with "--": -- sort X [+ |-] key [, [+ |-] key [,…] Select a multiple KEYS from the sort keys segment. the "+" character is optional, because the default direction is in ascending order of numbers or dictionary order. for example, ps-jax-sort = uid,-ppid, + pid. -- help: displays help information. -- version: displays the local version of the command. the sort key is mentioned in the preceding option description. Next, we will further describe the sort key. note that the land use value in the sorting operation is the internal value of the ps application, not only the pseudo value in some output formats. the following table lists the sort keys. =============== sort key list ================================== = c cmd executable simple name C cmdline complete command line f flags long mode Mark g pgrp process Location group IDG tpgid control tty process Group IDj cutime cumulative user time J cstime cumulative system time k utime user time K stime system Time m min_flt secondary page error count M maj_flt key page error Incorrect count n cmin_flt cumulative secondary page error N cmaj_flt cumulative key page error o session dialogue IDp pid process IDP ppid parent process IDr rss resident size R resident page s size memory size (kilobytes) S share page count t tty secondary device no. T start_time process start time U uid UIDu user username v vsize total number of local virtual memory (bytes) y priority kernel scheduling priority ====================== ps aux or lax output ================= 2. Explanation of ps aux or lax output au (x) output Format: user pid % CPU % mem vsz rss tty stat start time command user: process owner PID: Process ID % CPU: occupied CP U usage % MEM: occupied memory usage VSZ: occupied virtual memory size RSS: occupied memory size TTY: terminal secondary device number (minor device number of tty) STAT: process status: START: the TIME when the process is started; TIME: the cpu time consumed by the process; COMMAND: the COMMAND name and parameters; ======================= process STAT status ============================== d. The sleep state that cannot be interrupted (usually the IO process ); R is running, in the interrupted queue; S is in sleep and static state; T is stopped or tracked, paused; W is in memory switching (starting from kernel 2.6 is invalid ); X dead process; Z zombie process does not exist but cannot be eliminated temporarily; W: there is not enough memory paging to allocate the resources of the processes that WCHAN is waiting for; <: high-priority process N: low-priority process L: memory is allocated by Page and locked in memory (instant system or memory a I/O), that is, some pages are locked into memory s Process leader (with sub-processes under it); l multi-process (using CLONE_THREAD, similar to NPTL pthreads); + process Group in the background; ===================== kill terminate a process ============================== === killing a process involves more than a dozen methods to control the process, below are some common methods: kill-STOP [pid] sends SIGSTOP (17,19, 23) to STOP a process without killing it. Kill-CONT [pid] sends SIGCONT (, 25) to restart a stopped process. Kill-KILL [pid] sends SIGKILL (9) to force the process to stop immediately without cleaning. Kill-9-1 to terminate all processes you own. The SIGKILL and SIGSTOP signals cannot be captured, blocked, or ignored. However, other signals are acceptable. So this is your weapon. ======================== Example ================================ = $ psPID tty time COMMAND5800 ttyp0 00:00:00 bash5835 ttyp0 00:00:00 ps, project display area is divided into four items: PID (process ID), TTY (terminal name), TIME (process execution TIME), and COMMAND (COMMAND line input of the process ). you can use the u option to view the process owner and other details, as shown below: $ ps uUSER PID % CPU % mem usz rss tty stat start time COMMANDtest 5800 0.0 0.4 1892 1040 ttyp0 S Nov27-bashtest 5836 0.0 0.3 2528 856 ttyp0 R Nov27 ps u in the bash process there is a horizontal line in front, this means that the process is a user Log on to the shell, so for a login user, there is only one process with a short line. the options % CPU and % MEM are also displayed. The former indicates the percentage of CPU time and total time occupied by the process, and the latter indicates the percentage of memory occupied by the process and total memory. in this case, we can see all the processes that control terminals. of course, we still haven't observed other processes that do not control terminals. Therefore, we need to use the x option. you can use the x option to view all processes in the process. 1) ps a shows all programs under the current terminal, including those of other users. 2) ps-A shows all programs. 3) when listing programs in ps c, the real command name of each program is displayed without the path, parameter or resident service identifier. 4) the effect of this parameter is the same as that of the specified "A" parameter. 5) when listing programs, ps e displays the environment variables used by each program. 6) ps f uses ASCII characters to display the tree structure and express the relationship between programs. 7) the ps-H tree structure is displayed, indicating the relationship between programs. 8) ps-N shows all programs, except the programs under the ps command terminal. 9) ps displays the program status in the program signal format. 10) when listing programs in ps, it includes interrupted subroutines. 11) ps-t <终端机编号> Specify the terminal number and list the status of the program that belongs to the terminal. 12) ps u displays the program status in user-based format. 13) ps x shows all programs, which are not distinguished by terminals. The most common method is ps-aux, which is then directed to grep with the pipeline symbol to find a specific process and then operate on the specific process.
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.