Linux under the PS command detailed

Source: Internet
Author: User
Tags cpu usage

To monitor and control processes in the system, view status, memory,CPU usage, command:/bin/ps

(1) PS: is to show the status of the instantaneous process, not dynamic continuous;

(2) top: If you want to monitor the process running time, you should use the top command;

(3) Kill is used to kill the process or send a signal to the process;

(4) View the last man manual of the article to see the meaning of each output of PS toFind:standard FORMAT specifiers

===================================ps parameter Description =============================

l long format output;

U displays the process in the order of the user name and start time;

J Use the task format to display the process;

F to display the process in a tree-shaped format;

A shows all processes of all users (including other users);

X shows the process without control terminal;

R shows the running process;

WW avoids detailed parameters being truncated;


-A lists all processes
-W display widen to show more information
-au Show more detailed information
-aux Show all processes that contain other users

-e Show All Processes , environment variables
-F Full format
-H does not display the caption
-L Long format
-W Wide output
A shows all processes on the terminal , including other user processes
R shows only the running process
X shows no control of the terminal process

Our common options are the combination of aux or lax, and the application of parameter F.
PIDs lists only the process identifiers , separated by commas . The process list must be given immediately after the last option in the command line arguments , and no spaces can be inserted in the middle . For example:ps-f1,4,5 shows the process ID as the process of 1,4,5

The following describes the long command-line options , which begin with "--":
--sort x[+|-] key [, [+|-] key [,... ] ] Select A multi-letter key from the SORT keys section . + "characters are optional because the default direction is in ascending or dictionary order,"-"characters are sorted in reverse (that is, descending) .

For example: ps-jax-sort=uid,-ppid,+pid.
--HELP Displays help information .
--version Displays the version information for this command .

The sort key is mentioned in the previous option description and the sort key is further explained . It is important to note that the value used in the sorting is the intrinsic value of PS , not only for some output format pseudo -values. The list of sort keys is shown in the table below .

============ sort Key List==========================
C cmd executable simple name
C cmdline full command line
F Flags Long mode flag
G Pgrp Process Ground GroupId
G Tpgid ControlTTY Process GroupId
J Cutime Cumulative User Time
J Cstime Cumulative system time
K Utime User Time
K stime System Time
M Min_flt number of minor pages incorrectly
M Maj_flt Key page erroneously number
n Cmin_flt Cumulative Minor page error
N Cmaj_flt Cumulative Key page error
O Session DialogId
P PID ProcessId
P ppid Parent ProcessId
R RSS Resident Size
R Resident Resident Page
S size    memory size (Kbytes )  
S share    number of shared pages  
T tty   tty minor device number < Span lang= "en-US" > 
T start_time  process start time < Span lang= "en-US" > 
u uid   uid
u user    user name
V vsize    Total amount of virtual memory (byte ) &NBSP;
y priority  kernel scheduling priority
================================ ========ps aux  or  lax  output explanation =========================

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: CPU Usage consumed
%MEM: Memory usage consumed
VSZ: The amount of virtual memory occupied
RSS: The amount of memory consumed

TTY: Secondary device number for the terminal (minor device numbers of TTY)

STAT: Process status :

Start: The time to start the process;
Time: How long the process consumes the CPU;
Command: The name and parameters of the commands;

========================================= process stat status ==================================

D a dormant state (usually IO process) that cannot be interrupted;
R is running in an interruptible queue;
S in hibernation, stationary state;
T stop or be traced, suspend execution;
W enters memory swap ( invalid starting from kernel 2.6);
X the process of dying out;
Z Zombie process does not exist but cannot be eliminated temporarily;

W: Not enough memory paging to allocate
Wchan the process resources being awaited;

<: high-priority process
N: Low Priority sequence process
L: Memory paged and locked in memory (instant system or I/O), that is , some pages are locked into memory

Leader of the S-process (under it there are sub-processes);
L multi-process (using clone_thread, similar to NPTL pthreads);
+ Process Group located in the background;

========================================kill Terminate process ================================

Kill terminates the process

There are more than 10 ways to control the process, here are some common methods :

kill-stop [PID]
Send SIGSTOP (17,19,23) to stop a process without destroying it.

Kill-cont [PID]
Send Sigcont (19,18,25) to restart a stopped process.

Kill-kill [PID]
Send SIGKILL (9) forces the process to stop immediately and does not implement a cleanup operation.

Kill-9-1
Stop all the processes you have.

SIGKILL and SIGSTOP signals cannot be captured, blocked, or ignored, but other signals can. So this is your ultimate weapon.

================================================== Example ==============================

$ ps
PID TTY Time COMMAND
5800 ttyp0 00:00:00 Bash
5835 TTYP0 00:00:00 PS
As you can see , the displayed items are divided into four items , which are PID (process ID),TTY (terminal name ),time (Process execution times ),command (the process-to-line input ).

You can use the u option to view the process owner and a little more detail , as follows:
$ ps U
USER PID%cpu%MEM USZ RSS TTY STAT START time COMMAND
Test 5800 0.0 0.4 1892 1040 Ttyp0 S Nov27 0:00-bash
Test 5836 0.0 0.3 2528 856 ttyp0 R Nov27 0:00 PS u

there is a horizontal line in front of the bash process , which means that the process is a user logging in to the shell, so there is only one process for a logged-on user with a dash . You can also see the%CPU,%mem two options , The former refers to the CPU time occupied by the process

And the total time in percent ; the latter refers to the amount of memory that the process occupies and the percentage of total memory .
In this case, you see all the control of the terminal process, of course, for other those who do not control the terminal process is not observed , so the need to apply the x option . The x option allows you to observe all process conditions .

1) PS a  shows all programs under the current terminal, including those of other users.
2) ps-a  Show All Programs.
3) PS c  displays the actual instruction name of each program, without the indication of the path, parameter, or resident service when listing the program.
4) ps-e  The effect of this parameter is the same as specifying
5) PS e  Displays the environment variables used by each program when the program is listed.
6) PS f  uses ascii characters to display the tree structure, expressing the relationship between the programs.
7) ps-h  displays a tree structure that represents the inter-program relationship.
8) ps-n  shows all programs except the program that executes ps command terminal.
9) PS s  shows the program status in the format of the program signal.
) PS s  lists programs, including interrupted sub-program data.
One) ps-t< terminal number >  specifies the terminal number and lists the status of the program belonging to that terminal.
) PS u  Displays the status of the program in a user-oriented format.
) PS x  shows all programs, not differentiated by terminal.

The most common method is ps-aux, and then directed to grep with the pipe symbol to find a specific process

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.