Summary of Linux ps and pstree command knowledge points

Summary of Linux ps and pstree command knowledge points

The ps command in Linux is the abbreviation of Process Status. The ps command is used to list the processes currently running in the system. The ps command lists snapshots of the current processes, that is, the processes at the time when the ps command is executed. If you want to display process information dynamically, you can use the top command.

To monitor and control the process, you must first understand the current process status, that is, you need to view the current process, and the ps command is the most basic and also very powerful process viewing command. This command can be used to determine which processes are running and their running status, whether the processes have ended, whether the processes are dead, which processes are taking up too many resources, etc. In short, most of the information can be obtained by executing this command.

ps provides a one-time view of the process. The results it provides are not dynamic and continuous. If you want to monitor the process time, you should use the top tool.

The kill command is used to kill a process.

1. View all processes

ps -eF

-e: Select all processes.
-F: Extra full format.

PSR (Processor) shows the CPU where the process is located.

2. View all processes (including threads)

ps -eLF
-e: Select all processes.
-L: Show threads, possibly with LWP and NLWP columns.
-F: Extra full format.

LWP (Low Weight Process), displays the thread number TID. To the Linux kernel, there is no difference between the management of threads and processes. To the user, a process may contain multiple threads. If PID and LWP are the same, the thread is the main thread of the process.

3. View in custom format

ps -eLo pid,lwp,nlwp,sched,pri,psr,args

-e: Select all processes.
-L: Show threads, possibly with LWP and NLWP columns.
-o: User-defined format.

You can view the parameters you want to view, such as scheduling strategy, priority, etc.

4. pstree

To view processes/threads in a tree format use the pstree command.

pstree -p

-p: Show PIDs.

For the specific usage of ps and pstree, you may want to use the man command to view it.

The above are all the relevant knowledge points compiled by the editor. Thank you for your learning and support for 123WORDPRESS.COM.

<<:  Detailed graphic tutorial on how to install the unzipped version of MySQL under Windows 10

>>:  jQuery realizes the scrolling effect of table row data

Recommend

Enabling or disabling GTID mode in MySQL online

Table of contents Basic Overview Enable GTID onli...

Some conclusions on developing mobile websites

The mobile version of the website should at least...

Detailed installation and use of SSH in Ubuntu environment

SSH stands for Secure Shell, which is a secure tr...

The final solution to Chrome's minimum font size limit of 12px

I believe that many users who make websites will ...

How to use glog log library in Linux environment

Generate Linux library The Linux version uses cen...

Solution to overflow:hidden failure in CSS

Cause of failure Today, when I was writing a caro...

Analysis of the principle of centering elements with CSS

It is a very common requirement to set the horizo...

HTML validate HTML validation

HTML validate refers to HTML validation. It is the...

VMware Workstation 12 Pro Linux installation tutorial

This article records the VMware Workstation 12 Pr...

Nginx defines domain name access method

I'm building Nginx recently, but I can't ...

MySQL performance optimization tips

MySQL Performance Optimization MySQL is widely us...

A method of hiding processes under Linux and the pitfalls encountered

Preface 1. The tools used in this article can be ...

js realizes the magnifying glass effect of shopping website products

This article shares the specific code of js to ac...

The difference between ${param} and #{param} in MySQL

The parameter passed by ${param} will be treated ...