Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to query the process under linux

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to query the process under linux". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to query the process under linux".

Query process command: 1, ps command, can view the details of all running processes in the system, syntax "ps aux" or "ps-le"; 2, top command, can real-time monitor the running status of the process, syntax "top option"; 3, pstree command, can view the process tree, tree structure to display the relationship between the program and the process.

The operating environment of this tutorial: CentOS 6 system, Dell G3 computer.

A process is a program or command that is being executed, each process is a running entity, has its own address space, and takes up some system resources.

It is a daily routine for both Linux system administrators and ordinary users to monitor the operation of system processes and terminate some out-of-control processes at the right time.

Although commands are used for process management in Linux, the main purpose of process management is the same, that is, to view the programs and processes running in the system, to judge the health status of the server, and to force the termination of unwanted processes.

So what is the query process command under linux? The following article shares with you some commands for the linux query process.

Linux ps command: view running processes

The ps command is the most commonly used command for monitoring processes, which allows you to view the details of all running processes on the system.

The basic format of the ps command is as follows:

[root@localhost ~] # ps aux# view all processes in the system, use the BS operating system format [root@localhost ~] # ps-le# to view all processes in the system, and use the Linux standard command format

Options:

A: displays all processes of a terminal, except for session leads

U: displays the home user of the process and memory usage

X: displays the process without the control terminal

-l: displays more detailed information in a long format

-e: show all processes

As you can see, the ps command is a little different, and some of its options cannot be added with "-", such as the command "ps aux", where "aux" is the option, but it cannot be preceded by a "-".

If you execute the "man ps" command, you will find that the help of the ps command in order to adapt to different UNIX-like systems, there are many formats available, which are not convenient to remember. Therefore, I suggest you remember a few fixed options. For example:

"ps aux" can view all the processes in the system

"ps-le" can view all processes in the system, and can also see the PID and process priority of the parent process of the process.

"ps-l" can only see the processes generated by the current Shell

These three commands are enough, let's take a look at each of them.

[example 1]

[root@localhost ~] # ps aux# View all processes in the system USER PID% CPU% MEM VSZ RSS TTY STAT START TIME COMMANDroot 1 0.0 0.2 2872 1416? Ss Jun04 0:02 / sbin/initroot 2 0.0 0.0 0 0? S Jun04 0:00 [kthreadd] root 3 0.0 0.0 00? S Jun04 0:00 [migration/0] root 4 0.0 0.0 00? S Jun04 0:00 [ksoftirqd/0]... Omit part of the output.

The specific meaning of each column in the above output information is listed in Table 1.

Table 1 ps command output information meaning header meaning USER by which user the process was generated. ID of the PID process. % CPU the percentage of CPU resources consumed by the process, the higher the percentage, the more resources the process consumes. % MEM the percentage of physical memory consumed by the process, the higher the percentage, the more resources the process consumes. VSZ the amount of virtual memory consumed by the process, in KB. RSS the amount of actual physical memory occupied by the process, in KB. TTY the terminal on which the process is running. Among them, tty1~ tty7 represents the local console terminal (different terminals can be switched by Alt+F1 ~ F7 shortcut keys), tty1~tty6 is the local character interface terminal, and tty7 is the graphics terminal. Pts/0 represents a virtual terminal, usually a remote connection terminal. The first remote connection occupies pts/0, and the second remote connection occupies pts/1, which is longer in turn. STAT process status. The common states are as follows:

-D: a sleep state that cannot be awakened, usually used in the case of Ipicuro.

-R: the process is running.

-S: the process is asleep and can be awakened.

-T: stopped state, may be paused in the background or the process is in debug state.

-W: memory interaction state (invalid since 2.6 kernel).

-X: dead process (should not occur).

-Z: zombie process. The process has been aborted, but some programs are still in memory.

-

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report