In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you Linux how to view the details of the process, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
1. What is ps?
To monitor and control the process, you must first understand the current process, that is, you need to look at the current process, and the ps command is the most basic process view command. Use this command to determine which processes are running and running status, whether the process ends, whether the process has zombies, which processes take up too many resources, and so on. In short, most of the information can be obtained by executing the command.
Ps shows the status of the process in an instant, not dynamically continuous; if you want to monitor the process in real time, you should use the top command.
Basic parameters:
-A:
All processes are shown to have the same effect as-e
-a:
Displays all processes under the current terminal, including those of other users
-u:
User-based process status
X:
It is usually used with the parameter a to list more complete information.
Output format planning:
L:
List the information of the PID in longer and more detail
J:
Format of work (jobs format)
-f:
Make a more complete output.
Let's practice with a command to see what effect the different parameters have.
two。 What will be output if I execute the ps command without arguments?
This is a basic ps use, let's take a look at the console to execute this command and see the results.
The result displays 4 columns of information by default:
PID: the process number of the running command (CMD)
TTY: the location where the command runs (terminal)
TIME: the CPU processing time taken by the running command
CMD: the command that the process runs
This information is not sorted when it is displayed.
3. How do I display all current processes?
Use the-a parameter, where-a stands for all. At the same time, the x parameter will show the process without the control terminal.
The result of the command $ps-ax # may be long. For ease of viewing, you can use it in combination with less commands and pipes. $ps-ax | less
4. How to filter information based on the user of the process?
In cases where we need to view specific user processes, we can use the-u parameter. For example, to view the progress of user 'pungki', we can use the following command:
$ps-u pungki
5. How do I filter processes through cpu and memory usage?
Maybe you want to filter the results by CPU or memory usage, so you can find out which process is taking up your resources. To do this, we can use the aux parameter to display comprehensive information:
$ps-aux | less
When the results are long, we can use pipes and less commands to filter.
The default result set is not sorted. You can sort it with the-- sort command.
5.1 sort in ascending order according to CPU utilization
$ps-aux-- sort-pcpu | less
5.2 sort ascending according to memory usage
$ps-aux-- sort-pmem | less
5.3 We can also merge them into a single command and display the top 10 results through pipes:
$ps-aux-- sort-pcpu,+pmem | head-n 10
6. How do you filter by process name and PID?
Use the-C parameter, followed by the name of the process you are looking for. For example, to display information about a process named getty, you can use the following command:
$ps-C getty
If you want to see more details, we can use the-f parameter to view the list of formatted information:
$ps-f-C getty
7. How do you filter processes based on threads?
If we want to know the thread of a particular process, we can use the-L parameter, followed by a specific PID.
$ps-L 1213
8. How to display the progress in a tree?
Sometimes we want to display the process in a tree structure, using the-axjf parameter.
$ps-axjf
Or you can use another command.
$pstree
9. How do I display security information?
If you want to see who has logged in to your server now. You can use the ps command plus related parameters:
$ps-eo pid,user,args
The parameter-e displays all process information, and the-o parameter controls the output. The Pid,User and Args parameters show PID, the user running the application, and the application.
The keywords that can be used with the-e parameter are args, cmd, comm, command, fname, ucmd, ucomm, lstart, bsdstart, and start.
10. How do I format processes created by output root users (real or valid UID)?
When the system administrator wants to view the process run by the root user and other related information about this process, you can use the following command:
$ps-U root-u root u
The-U parameter filters the process by real user ID (RUID), which selects the real user name or ID from the user list. The real user is the user who actually created the process.
The-u parameter is used to filter the valid user ID (EUID).
The final u parameter is used to determine the output format for the user, which consists of the columns User, PID,% CPU,% MEM, VSZ, RSS, TTY, STAT, START, TIME and COMMAND.
Here is the output of the above command:
11. How to use PS to monitor process status in real time?
The ps command shows the current process status of your system, but the result is static.
When there is a situation, we need to filter the process by CPU and memory usage, as mentioned in point 4 above, and we want the results to be refreshed every second. To do this, we can combine the ps command with the watch command.
$watch-n 1'ps-aux-sort-pmem,-pcpu'
If the output is too long, we can also limit it, such as the first 20 items, which we can do with the head command.
$watch-n 1'ps-aux-- sort-pmem,-pcpu | head 20'
The dynamic view here is not like the top or htop commands. But the advantage of using ps is that you can define the fields that are displayed, and you can select the fields you want to view.
For example, if you only need to see the information of the user named 'pungki', you can use the following command:
$watch-n 1'ps-aux-U pungki u-- sort-pmem,-pcpu | head 20'
twelve。 Last
You may use the ps command to monitor your Linux system every day. But in fact, you can generate all kinds of reports you need through the parameters of the ps command.
Another advantage of the ps command is that ps is installed by default on all Linux systems, so all you have to do is use it. Don't forget to check out more parameters through man ps.
The above is all the contents of the article "how to check the process details of Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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: 277
*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.