In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to use the process View Serial PS command in linux. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
1. Introduction to ps the two commands (who and w commands) described earlier are used to view the current system users. Let's take a look at the process, which is also the topic of this chapter. In order to monitor and control the process, we must first understand the current process, that is, we need to look at the current process, and the ps command is the most basic and powerful linux process view command. Use this command to determine which processes are running and running status, whether the process ends, whether the process is dead, which processes are taking up too much resources, and so on. In short, most of the information can be obtained by executing the command.
2. Ps command and its parameters
The ps command is most commonly used to monitor the work of background processes, because background processes do not communicate with standard input / output devices such as on-screen keyboards, so if you need to detect their situation, you can use the ps command.
The syntax format of the command is as follows: ps [options]
The command options are described below:
◆-e shows all processes.
◆-f full format.
◆-h does not display the title.
◆-l long format.
◆-w wide output.
◆ a displays all processes on the terminal, including those of other users.
◆ r shows only the running processes.
◆ x shows the process that does not control the terminal.
O[ + | -] K1 [, [+ | -] K2 [, …]] Displays a list of processes based on the multi-level sort order specified by the shortcut keys in SHORT KEYS, K1, and K2. There are default sequential assignments for different formats of ps. These default orders can be overridden by the user's assignment. Where the "+" character is optional and the "-" character reverses the direction of the specified key.
Pids lists only the circumstances of the specified process. Process ID is separated by commas. The list of processes must be given immediately after an option in the command line argument, with no spaces inserted in the middle. For example: ps-F1, 4 and 5.
The following describes the long command line options, all of which start with "-":
◆-- sort X [+ | -] key [, [+ | -] key [, …]] Select a multi-letter key from the SORT KEYS section. The "+" character is optional because the default direction is ps-jax-sort=uid,-ppid,+pid in ascending numerical order or dictionary Chengjie.
◆-- help displays help information.
◆-- version displays the version information of the command.
The sort key is mentioned in the previous option description, followed by a further explanation of the sort key. It is important to note that the values used in sorting are internal values used by ps and are not only used for pseudo values in some output formats.
Sort key list
Short format
Long format
State clearly
Simple name of the ◆ c-cmd executable
◆ C-cmdline full command line
◆ f-flags long mode flag
Group ID of the ◆ g-pgrp process
◆ G-tpgid controls the tty process group ID
◆ j-cutime cumulative user time
◆ J-cstime cumulative system time
◆ k-utime user time
◆ K-stime system time
Number of ◆ m-min_flt secondary page errors
Number of ◆ M-maj_flt main page errors
◆ n-cmin_flt accumulate secondary page errors
◆ N-cmaj_flt accumulates main page errors
◆ o-session conversation ID
◆ p-pid process ID
◆ P-ppid parent process ID
◆ r-rss resident size
◆ R-resident resident Page
◆ s-size memory size (kilobytes)
Number of ◆ S-share shared pages
◆ t-ttytty secondary device number
Time when the ◆ T-start_time process started
◆ U-uid-UID
◆ u-user user name
Total amount of virtual memory for ◆ v-vsize (bytes)
◆ y-priority kernel scheduling priority
3. Common ps command parameters
The parameters described in the previous two sections may make the reader feel a little scary, in fact, this is a very easy to use command, the average user only needs to master some of the most commonly used command parameters. The three most commonly used parameters are u, a, and x, which will be illustrated by examples below.
Log in to the system as root to view the current process status
$ps
PID TTY TIME COMMAND
5800 ttyp0 00:00:00 bash
5835 ttyp0 00:00:00 ps
As you can see, the items displayed are divided into four items: PID (process ID), TTY (terminal name), TIME (process execution time), and COMMAND (command line input for the process).
Use the u option to view the process owner and other details, as follows:
$ps u
USER PID CPU MEM USZ RSS TTY STAT START TIME COMMAND
Test 5800 0.00.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 the user's login shell, so there is only one process with a dash for a logged-in user. You can also see the% CPU and% MEM options, the former refers to the percentage of CPU time and total time consumed by the process, and the latter refers to the percentage of memory and total memory consumed by the process.
In this case, you see all the processes that control the terminal; but for other processes that do not control the terminal, it is still not observed, so you need to use the x option at this point. All processes can be observed using the x option.
Here is an example of using the x option:
$ps x
PID TTY STAT TIME COMMAND
5800 ttyp0 S 0:00-bash
5813 ttyp1 S 0:00-bash
5921 ttyp0 S 0:00 man ps
5922 ttyp0 S 0:00 sh-c / usr/bin/gunzip-c / var/catman/cat1/ps.1.gz | /
5923 ttyp0 S 0:00 / usr/bin/gunzip-c / var/catman/cat1/ps.1.gz
5924 ttyp0 S 0:00 / usr/bin/less-is
5941 ttyp1 R 0:00 ps x
You can see that there are so many more processes all of a sudden. These extra processes are those that do not control the terminal.
All the processes seen earlier are owned by the test user. In fact, there are many other users using the system, which naturally corresponds to many other processes. If you want to know something about these processes, you can use the an option to view all processes for all users of the current system. The aux combination option is often used, which shows the most detailed process.
$ps aux
USER PID CPU MEM VSZ RSS TTY STAT START TIME COMMAND
Root 1 0.0 0.0 1136 64? S Nov25 0:02 init [3]
Root 2 0.0 0.0 0 0? SW Nov25 0:00 [kflushd]
Root 3 0.0 0.0 0 0? SW Nov25 0:03 [kupdate]
Root 4 0.0 0.0 0 0? SW Nov25 0:00 [kpiod]
Root 5 0.0 0.0 0 0? SW Nov25 0:00 [kswapd]
Root 163 0.0 0.1 1628 332? S Nov25 0:02 sshd
Root 173 0.0 0.0 1324 200? S Nov25 0:00 syslogd
Root 181 0.0 0.0 1420 0? SW Nov25 0:00 [klogd]
Daemon 191 0.0 0.1 1160 312? S Nov25 0:00 / usr/sbin/atd
Root 201 0.0 0.1 1348 492? S Nov25 0:00 crond
Root 212 0.0 0.0 1292 68? S Nov25 0:00 inetd
……
At the front of the display is the process of other users, you can see root, daemon and other users and the processes they started. In the above example, some of the most common options and combinations of options for the ps command are introduced, which users can choose according to their own needs.
On the "linux process view serial PS command how to use" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, please share it out for more people to see.
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.