One linux command every day (41): ps command

Source: Internet
Author: User
Tags touch command
One linux command every day (41): ps command link: One linux command every day (1): ls command http://www.2cto.com/os/201210/163049.html ; One linux command every day (2): cd command http://www.2cto.com/os/201210/163050.html A linux command every day (41): ps command link: A linux command every day (1): ls command http://www.2cto.com/os/201210/163049.html ; One linux command every day (2): cd command http://www.2cto.com/os/201210/163050.html ; One linux command every day (3): pwd command http://www.2cto.com/os/201210/163462.html ; One linux command every day (4): mkdir command http://www.2cto.com/os/201210/163463.html ; One linux command every day (5): rm command http://www.2cto.com/os/201210/163662.html ; One linux command (6) every day: rmdir command http://www.2cto.com/os/201210/164017.html ; One linux command (7) every day: mv command http://www.2cto.com/os/201210/164247.html ; One linux command every day (8): cp command http://www.2cto.com/os/201210/164254.html ; One linux command every day (9): touch Command http://www.2cto.com/os/201211/165699.html ; One linux command every day (10): cat command http://www.2cto.com/os/201211/165989.html ; One linux command every day (11): nl command http://www.2cto.com/os/201211/165990.html One linux command every day (12): more command http://www.2cto.com/os/201211/165994.html One linux command every day (13): less command http://www.2cto.com/os/201211/165998.html One linux command every day (14): head Command http://www.2cto.com/os/201211/166191.html One linux command every day (15): tail command http://www.2cto.com/os/201211/168702.html One linux command every day (16): which command http://www.2cto.com/os/201211/168890.html A linux command (17) every day: whereis command http://www.2cto.com/os/201211/168893.html One linux command (18) every day: locate command http://www.2cto.com/os/201211/168895.html One linux command every day (19): find command overview http://www.2cto.com/os/201211/168897.html One linux command every day (20): find command exec http://www.2cto.com/os/201211/168901.html One linux command (21) every day: find command xargs http://www.2cto.com/os/201211/168903.html A linux command (22) every day: detailed description of the parameters of the find Command http://www.2cto.com/os/201211/168912.html A linux command (23) every day: Linux directory structure http://www.2cto.com/os/201211/170430.html One linux command every day (24): Linux file type and extension http://www.2cto.com/os/201211/170431.html One linux command every day (25): Explanation of linux file attributes http://www.2cto.com/os/201211/170434.html One linux command every day (26): use SecureCRT to upload and download files http://www.2cto.com/os/201211/172022.html One linux command every day (27): linux chmod command http://www.2cto.com/os/201211/172028.html One linux command every day (28): tar command http://www.2cto.com/os/201212/172641.html One linux command (29) every day: chgrp command http://www.2cto.com/os/201212/172983.html One linux command every day (30): chown command http://www.2cto.com/os/201212/173239.html A linux command (31) every day:/etc/group file details http://www.2cto.com/os/201212/174429.html One linux command (32) every day: gzip command http://www.2cto.com/os/201212/174431.html One linux command every day (33): df command http://www.2cto.com/os/201212/174434.html One linux command every day (34): du command http://www.2cto.com/os/201212/174701.html One linux command (35) every day: ln command http://www.2cto.com/os/201212/174993.html One linux command (36) every day: diff command http://www.2cto.com/os/201212/176333.html One linux command (37) every day: date Command http://www.2cto.com/os/201212/176335.html One linux command (38) every day: cal command http://www.2cto.com/os/201212/176337.html One linux command (39) every day: grep command http://www.2cto.com/os/201212/177059.html One linux command every day (40): wc command http://www.2cto.com/os/201212/177343.html The ps command in Linux is short for Process Status. The ps command is used to list the processes currently running in the system. The ps command lists the snapshots of the current processes, that is, those processes that run the ps command at that time. if you want to dynamically display process information, you can use the top command. To monitor and control the process at www.2cto.com, you must first understand the current process, that is, view the current process. the ps command is the most basic and powerful process View command. You can use this command to determine which processes are running and running, whether the process is terminated, whether the process is dead, and which processes are occupying excessive resources. In short, most of the information can be obtained by executing this command. Ps provides a one-time view of the process. The results are not dynamically consecutive. to monitor the process time, use the top tool. The kill command is used to kill a process. There are 5 Processes in linux: 1. running (running or waiting in the running queue) 2. interruption (sleep, blocked, waiting for the formation of a condition or receiving a signal) 3. do not interrupt (do not wake up when receiving the signal or do not run, the process must wait until an interruption occurs) 4. dead (the process has been terminated, but the process descriptor exists until the parent process calls wait4 () released after the system call) 5. stop (the process stops running after receiving SIGSTOP, SIGSTP, SIGTIN, and SIGTOU signals) five status codes of the process identified by the PS tool: D uninterruptible sleep (usually IO) R run runnable (on run queue) S interrupt sleeping T stop traced or stopped Z stiff a defunct ("zombie") process 1. command format: ps [parameter] 2. command: displays the status of the current process. command parameters: a: show all processes-a: show all programs under the same terminal-A: show all processes c: show the real name of the process-N: Select-e to be equal to "-A" e: show the environment variable f show the relationship between programs-H display tree structure r show the processes of the current terminal T show all programs of the current terminal u all processes of the specified user-au show more detailed information-aux show all include the itinerary of other users-C <命令> List the status of a specified command-lines <行数> Number of rows displayed per page -- width <字符数> Number of characters displayed on each page -- help display help information -- version display version Display 4. use instance: instance 1: display all process information command: ps-A output: [root @ localhost test6] # ps-a pid tty time cmd 1? 00:00:00 init 2? 00:00:01 migration/0 3? 00:00:00 ksoftirqd/0 4? 00:00:01 migration/1 5? 00:00:00 ksoftirqd/1 6? 00:29:57 events/0 7? 00:00:00 events/1 8? 00:00:00 khelper 49? 00:00:00 kthread 54? 00:00:00 kblockd/0 55? 00:00:00 kblockd/1 56? 00:00:00 kacpid 217? 00:00:00 cqueue/0 ...... Partial result description: instance 2: displays the specified user information. Command: ps-u root output: [root @ localhost test6] # ps-u root pid tty time cmd 1? 00:00:00 init 2? 00:00:01 migration/0 3? 00:00:00 ksoftirqd/0 4? 00:00:01 migration/1 5? 00:00:00 ksoftirqd/1 6? 00:29:57 events/0 7? 00:00:00 events/1 8? 00:00:00 khelper 49? 00:00:00 kthread 54? 00:00:00 kblockd/0 55? 00:00:00 kblockd/1 56? 00:00:00 kacpid ...... Partial result description: instance 3: displays all process information, together with the command line command: ps-ef output: www.2cto.com [root @ localhost test6] # ps-efUID pid ppid c stime tty time CMDroot 1 0 0 Nov02? 00:00:00 init [3] root 2 1 0 Nov02? 00:00:01 [migration/0] root 3 1 0 Nov02? 00:00:00 [ksoftirqd/0] root 4 1 0 Nov02? 00:00:01 [migration/1] root 5 1 0 Nov02? 00:00:00 [ksoftirqd/1] root 6 1 0 Nov02? 00:29:57 [events/0] root 7 1 0 Nov02? 00:00:00 [events/1] root 8 1 0 Nov02? 00:00:00 [khelper] root 49 1 0 Nov02? 00:00:00 [kthread] root 54 49 0 Nov02? 00:00:00 [kblockd/0] root 55 49 0 Nov02? 00:00:00 [kblockd/1] root 56 49 0 Nov02? 00:00:00 [kacpid]... Partial results are omitted. Example 4: common combinations of ps and grep are used to find specific process commands: ps-ef | grep ssh output: [root @ localhost test6] # ps-ef | grep sshroot 2720 1 0 Nov02? 00:00:00/usr/sbin/sshdroot 17394 2720 0? 00:00:00 sshd: root @ pts/0 root 17465 17398 0 00:00:00 pts/0 grep ssh note: instance 5: list the current PID and related information for your login. command: ps-l output: [root @ localhost test6] # ps-lF s uid pid ppid c pri ni addr sz wchan tty time limit 4 S 0 17398 17394 16543 0 75 0-wait pts/0 00:00:00 bash4 R 0 17469 17398 0 77 0-15877-pts/0 00:00:00 ps description: significance of relevant information: F represents the flag of the program, 4 represents the super userS represents the state of the program (STAT ), the meaning of each STAT will be described in UID The PID owned by this UID is the ID of this program! PPID is the percentage of resources used by the idc cpu of the Parent Program. PRI is the abbreviation of Priority (Priority execution order, in the next section, we will continue to introduce ADDR, which is a kernel function and specifies the part of the program in the memory. If it is a running program, it is generally "-" the memory size used by sz wchan. is this program currently running, if-indicates the cpu time used by the terminal location TIME of the TTY login operator. Why is the preset command issued by CMD only lists the PID related to the current bash shell? so when I use ps-l, there are only three PIDs. Instance 6: list all program commands in memory: ps aux output: [root @ localhost test6] # ps auxUSER PID % CPU % mem vsz rss tty stat start time COMMANDroot 1 0.0 0.0 10368 676? Ss Nov02 init [3] root 2 0.0 0.0 0 0? S <Nov02 01 [migration/0] root 3 0.0 0.0 0 0? SN Nov02 [ksoftirqd/0] root 4 0.0 0.0 0 0? S <Nov02 01 [migration/1] root 5 0.0 0.0 0 0? SN Nov02 [ksoftirqd/1] root 6 0.0 0.0 0 0? S <Nov02 29:57 [events/0] root 7 0.0 0.0 0 0? S <Nov02 [events/1] root 8 0.0 0.0 0 0? S <Nov02 [khelper] root 49 0.0 0.0 0 0? S <Nov02 [kthread] root 54 0.0 0.0 0 0? S <Nov02 [kblockd/0] root 55 0.0 0.0 0 0? S <Nov02 [kblockd/1] root 56 0.0 0.0 0 0? S <Nov02 [kacpid]…… Partial result description: USER: The process belongs to the USER account's PID: Number of the process % CPU: Percentage of CPU resources used by the process % MEM: percentage of physical memory occupied by the process VSZ: virtual memory used by the process (Kbytes) RSS: the fixed amount of memory occupied by the process (Kbytes) TTY: the process operates on the terminal. if it is irrelevant to the terminal, it will display ?, In addition, the tty1-tty6 is the login program on the machine, if the pts/0 and so on, it indicates the program connected to the host by the network. STAT: the current state of the program. The main state is R: The program is currently running, or it can be operated. S: The program is currently sleeping (it can be said that it is in the idle state ), however, it can be awakened by some signals. T: The program is currently detecting or stopping Z: The program should have been terminated, but its parent program cannot terminate it normally, resulting in the status START of the zombie program: TIME when the process is triggered: the actual CPU usage TIME of the process COMMAND: the actual COMMAND instance of the program 7: list the program display commands similar to the program tree: output from www.2cto.com ps-axjf: [root @ localhost test6] # ps-axjfWarning: bad syntax, perhaps a bogg '-'? See/usr/share/doc/procps-3.2.7/faq ppid pid pgid sid tty tpgid stat uid time command 0 1 1 1? -1 Ss 0 0: 00 init [3] 1 2 1 1? -1 S <0 0: 01 [migration/0] 1 3 1? -1 SN 0: 00 [ksoftirqd/0] 1 4 1? -1 S <0 0: 01 [migration/1] 1 5 1 1? -1 SN 0: 00 [ksoftirqd/1] 1 6 1? -1 S <0 29:58 [events/0] 1 7 1 1? -1 S <0 0: 00 [events/1] 1 8 1 1? -1 S <0 0: 00 [khelper] 1 49 1 1? -1 S <0 0: 00 [kthread] 49 54 1 1? -1 S <0 0: 00 \ _ [kblockd/0] 49 55 1 1? -1 S <0 0: 00 \ _ [kblockd/1] 49 56 1 1? -1 S <0 \ _ [kacpid] description: instance 8: Find the PID number related to the cron and syslog services. Command: output: [root @ localhost test6] # ps aux | egrep '(cron | syslog) 'root 2682 0.0 0.0 83384 2000? Sl Nov02/sbin/rsyslogd-I/var/run/syslogd. pid-c 5 root 2735 0.0 0.0 74812 1140? Ss Nov02 crondroot 17475 0.0 0.0 61180 832 pts/0 S + egrep (cron | syslog) [root @ localhost test6] # Description: www.2cto.com other instances: 1. you can use the command "ps-aux | more2." to display all input paths and output them to the ps001.txt File: ps-aux> ps001.txt3. output the specified field command: ps-o pid, ppid, pgrp, session, tpgid, comm output: [root @ localhost test6] # ps-o pid, ppid, pgrp, session, tpgid, comm pid ppid pgrp sess tpgid COMMAND17398 17394 17398 17398 17478 bash17478 17398 17478 17398 17478 ps [root @ localhost test6] #
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.