In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "the usage of the Linux basic command ps". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the usage of the Linux basic command ps".
Ps
The ps instruction can display information about the current process in the system, and its output is highly customizable. If you want to update the selection and displayed information repeatedly, use top (1) instead.
Note that "ps-aux" is different from "ps aux". The POSIX and UNIX standards require "ps-aux" to print all processes owned by a user named "x" and all processes selected by the-an option. If a user named "x" does not exist, this ps can interpret the command as "ps aux" and print a warning. This behavior is designed to help convert old scripts and habits. It is fragile and can change at any time, so it should not be relied on.
By default, ps selects all processes with the same valid user ID (EUID=EUID) as the current user and the terminal associated with the caller. It displays the process ID (PID=PID), the terminal associated with the process (tname=TTY), the cumulative CPU time (time=TIME) in [dd-] hh:mm:SS format, and the executable name (ucmd=CMD). The output is not sorted by default.
Using the BSD style option adds the process status (stat=STAT) to the default display and displays the command args (args= command) instead of the executable name. You can override this operation using the PS_FORMAT environment variable. Using the BSD-style option also changes the process selection to include processes on other terminals (TTY) that you own, or this can be described as a collection of all processes that the selection is set to filter to exclude processes owned by other users or processes on the terminal. When the option is described as "the same", these effects are not taken into account, so-M will be considered the same as Z, and so on.
The scope of this command: RedHat, RHEL, Ubuntu, CentOS, SUSE, openSUSE, Fedora.
1. Grammar
Ps [options]
2. List of options
Option
Description
-- help
Show help documentation
-V | V |-- version
Show command version
-- info
Display debugging information
L
List all formats
Simple option
-A |-e
Select all processes
-N |-- deselect
Reverse selection does not meet the criteria
T
Select the terminal that matches
-a
Select all processes except session processes and terminal-independent processes.
A
This option causes ps to list all processes with terminals (TTY), or all processes when used with the x option.
-d
Select all processes and ignore the process owner
G
All processes, including session leadership
R
Limit the selection to run only the process.
X
This option causes ps to list all the processes you own (the same EUID as ps), or to list all processes when used with the an option.
Multiple option
These options accept individual parameters in a blank-separated or comma-separated list. They can be used many times.
-Ccmdlist
Select by command name. This selects the process that gives the executable name in the cmdlist.
-Ggrplist
Select the process to which the group id that the process belongs to matches the given list
Uuserlist
Select by valid user ID (EUID) or name. Valid user ID describes the user whose file access permissions are used by the process
-Uuserlist
Select by actual user ID (RUID) or name. The real user ID identifies the user who created the process
-ggrplist
Select by session or valid group name.
P pidlist
Select by process ID.
-ppidlist
Select by process ID.
-ssesslist
Select according to session ID
T ttylist
Select via tty. Almost the same as-t and-- tty, but can also be used with an empty ttylist to indicate the terminal associated with the ps.
-t ttylist
Select the specified tty
-uuserlist
Select by valid user ID (EUID) or name, which is equivalent to "U and"-- user "
-- Groupgrplist
Equivalent to "- G"
-- Useruserlist
Equivalent to "- U"
-- groupgrplist
Select by valid group ID (EGID) or name. Valid group ID describes the group for which the process uses its file access permissions.
-- pidpidlist
Equivalent to "- p" and "p"
-ppidppidlist
Select the id matching process of the parent process
-- sidsesslist
Equivalent to "- s"
-- ttyttylist
Equivalent to "- t" and "t"
-- useruserlist
Equivalent to "- u" and "U"
-123
Equivalent to "--sid 123"
one hundred and twenty three
Equivalent to "- pid 123"
3. Output format control
Format
Description
-f |-F
Output the complete format. It also causes command parameters to be output. When used with-L, the NLWP (number of threads) and LWP (thread ID) columns are added.
-Oformat
Similar to-o, but preloaded with some default columns. Equivalent to "- o pid,format,state,tname,time,command" or "- o pid,format,tname,time,cmd"
Oformat
Preloaded o. When used as a formatting option, it is exactly the same as-O and has a BSD personality.
-M
Add a list of security data.
X
Register format
Z
Equivalent to "- M"
-c
Displays different scheduler information for the-l option.
J
BSD job control format
-j
Job format
L
BSD long format
-l
Long format, often used with "- y"
Oformat
Equivalent to "- o" and "--format"
-oformat
User-defined format. Format is a single parameter in the form of a space-separated or comma-separated list that provides a way to specify a single output column. The header can be renamed as needed (ps-o pid,ruser=RealUser-o comm=Command). If all column headings are ps-o pid=-o comm=, the header row will not be output. The column width required for wide headers will increase; this can be used to extend columns such as WCHAN (ps-o pid,wchan=WIDE-WCHAN-COLUMN-o comm). Explicit width control (ps opid,wchan:42,cmd) is also provided. The behavior of ps-o pid=X,comm=Y varies with personality, and the output may be a column named "XGraincommuy" or two columns named "X" and "Y". Use the PS_FORMAT environment variable to specify default values as needed; DefSysV and DefBSD are macros that can be used to select default UNIX or BSD columns.
S
Display signal format
U
User-oriented mode
V
Virtual memory-based mode
-y
Do not display flag bits
-Z
Show security context format
-- formatformat
Same as "- o"
-- context
Show security context format
4. Output modifier
Modifier
Description
-H
Show process hierarchy
O order
Sorting, outdated operation
S
Summarize some information, such as CPU usage, from dead child process to parent process.
C
Displays the real command name. This is derived from the name of the executable file, not from the argv value. Therefore, the command parameters and any modifications to them are not displayed
E
Display the environment after the command
F |-- forest
Process hierarchy in ASCII format
H
No head.
K spec
Specify the sort order, equivalent to "--sort"
-nnamelist | N namelist
Proper WCHAN display requires a name list file and must exactly match the current Linux kernel to get the correct output. If this option is not available, the default search path for the name list is:
$PS_SYSMAP
$PS_SYSTEM_MAP
/ proc/*/wchan
/ boot/System.map- `uname-r`
/ boot/System.map
/ lib/modules/ `uname-r` / System.map
/ usr/src/linux/System.map
/ System.map
N
Digital output of WCHAN and User. (including all types of UID and GID)
-w | w
Wide output, use this option twice for infinite width
-- cols n |-- columns n |-- width n
Set the screen width
-- cumulative
Includes some dead child process data (as the sum of the parent process)
-- headers
Repeat the header line to output one line per page
-- no-headers
The title line is not printed at all
-- lines n |-- rows n
Set the screen height
-- sort spec
Sort. The syntax is "[+ | -] key [, [+ | -] key [,...]], for example, ps jax-- sort=uid,-ppid,+pid
5. Thread mode
Thread mode
Description
H
Display threads as processes
-L
Display the LWP NLWP of the thread
-T
Display the SPID of the thread
M |-m
Display threads after a process
6. Description
This ps works by reading the virtual file in "/ proc". This ps does not need to be a setuid kmem, nor does it require any privileges to run. Do not give this ps any special permissions. This ps requires access to the name list data to get the correct WCHAN display. For kernels prior to 2.6, the System.map file must be installed.
CPU usage is currently expressed as the percentage of time that the process has been running throughout the lifecycle. CPU usage is unlikely to reach 100%.
The SIZE and RSS fields do not calculate parts of the process, including page tables, kernel stacks, structures thread_info, and task_struct. This is usually at least the memory size of 20kb. SIZE is the virtual size of the process (code data stack).
Processes marked "defunct" are dead processes (so-called "zombies") because their parent process did not destroy them correctly. If the parent process exits, init (8) destroys those processes.
If the length of the user name is greater than the length of the display column, the digital user ID is displayed.
7. Process flag
The sum of these values is displayed in the F column, which is provided by the flag output specifier.
1, already fork, but not executed.
4, use superuser privileges.
8. Process status code
Here are the different values that the s, stat, and state output specifiers (header "stat" or "S") will display to describe the state of the process:
D, uninterrupted sleep (usually IO).
R, running or runnable (on the run queue).
S, can interrupt sleep (wait for the event to complete).
T, stop, either blocked by the job control signal, or because it is being tracked.
W, paging (invalid since the 2.6.xx kernel).
X, dead (should not be seen).
Z, stopped ("zombie") process, terminated but not harvested by its parent process.
For bsd format and when using the stat keyword, additional characters may be displayed:
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.