The Linux ps command is mainly used to check the running process of the system, and determine whether the state machine running the process occupies too many resources. The following small series through the examples to give you a detailed introduction to the Linux ps command, together to understand.
Linux provides the current process at the same time, such as user ID, CPU usage, memory usage, command name, etc., it is not Detailed real-time data, such as top or htop command is displayed. However, even if the function and output are simple, it is still a must-have process management/monitoring tool. Every Linux novice should know this and study hard. In this article, we'll use the ps command to view processes, filter, and sort them in different ways to enhance the underlying parts.
Syntax Note:
The ps command comes in two different styles, BSD and UNIX. New users often confuse and misinterpret these two styles. So to figure them out, here are some basic information before proceeding.
Note: & ldquo;ps aux” is not the same as “ps -aux”. For example, “-u” is used to display the user's process. But “u” is showing detailed information.
BSD Style: No hyphens in front of BSD-style grammar options.
ps aux
UNIX/LINUX style: There is a dash in front of the linux-style syntax option. …
ps -ef
Mixing the grammatical styles of two Linux systems is a good thing. For example, & ldquo;ps ax” In this article, we will focus on the UNIX-style syntax.
How to use the ps command?
1. Display all processes:
The following command will list all processes
$ ps ax
$ ps -ef
Add the pipe output to less, to scroll through the
“u” or “-f” parameters to display the details of all processes
$ ps aux
$ ps -ef -f
Note: Why does the user column not display my username, but other users, such as root, www, etc., for all usernames (including you) if the length is greater than 8 The character, then ps will only display the UID, not the username.
2, according to the user display process:
is used by the user of the process using &l“&rdq” user name to display. Multiple usernames can be provided separated by commas.
$ ps -f -u www-data
UID PID PPID C STIME TTY TIME CMD
www-data 1329 1328 0 09:32 ? 00:00:00 nginx: worker process
www-data 1330 1328 0 09:32 ? 00:00:00 nginx: worker process
www-data 1332 1328 0 09:32 ? 00:00:00 nginx: worker process
www-data 1377 1372 0 09:32 ? 00:00:00 php-fpm: pool a.localhost
www-data 1378 1372 0 09:32 ? 00:00:00 php-fpm: pool a.localhost
www-data 4524 2359 0 10:03 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 4527 2359 0 10:03 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 4528 2359 0 10:03 ? 00:00:00 /usr/sbin/apache2 -k start
3. Display the process by name and process ID:
Search for the process by name or command, use &l“& Rdq” plus search terms.
$ ps -C apache2
PID TTY TIME CMD
2359 ? 00:00:00 apache2
4524 ? 00:00:00 apache2
4525 ? 00:00:00 apache2
. . .
4, sort according to CPU or memory:
Department administrators often want to find processes that consume a lot of memory or CPU. Sorting options sort the list of processes based on specific fields or parameters.
“–sort&r” Multiple fields separated by commas can be specified. In addition, this field can be prefixed with &l“rdquo; or &l”dquo; symbols, indicating descending or ascending ordering. There are many parameters to sort through the process list, you can check the full list of man pages.
$ ps aux --sort=-pcpu,+pmem
Shows the top 5 CPU processes that consume most of them.
$ ps aux --sort=-pcpu
After Debian mounts the mobile hard disk, some partitions will be recognized, and some partitions wi
There are many ways to add a Linux string. One is to add a string at the beginning and end of the te
Linux system will generate many useless small files after a long time of use. If you need to waste a
Linux system for the MariaDB database this open source free small database is not unfamiliar, althou
Domestic system Linux Deepin 2014 detailed evaluation
The difference between Linux and Windows systems
Linux SecureCRT Tips for Uploading and Downloading Files
How Linux uses Sysdig to troubleshoot system faults
Linux system filezille file modification time is not correct how to do?
Ubuntu install Nox, compile make error, what should I do?
Linux how to use the whereis command to quickly find the file
Linux steps to start an Oracle database using commands
How to adjust the resolution and screen refresh rate of Ubuntu system?
How to customize the mouse pointer under Win8 system to make it more personalized
Cancel WinXP boot self-test skills five
How much do you know about the security mode of the operating system?
Black looping software in Windows is far from the trouble of rogue software
Five Windows 7 suspended animation scenarios and processing methods
How do my world's little zombies fight? My world's little zombies play Raiders