How to view all running processes in Linux

Source: Internet
Author: User

You can use the ps command. It displays information about the currently running process, including the PID of the process. Both Linux and UNIX support the ps command to display information about all running processes. The ps command can provide a snapshot of the current process. If you want to automatically refresh the status, you can use the top command.

Ps command

Enter the following ps command to display all running processes:

# ps aux | less

Where,

-A: displays all processes.

A: displays all processes of other users in the terminal.

X: displays the process of the uncontrolled terminal.

Task: view every process in the system.

# ps -A# ps -e

Task: view non-root Processes

# ps -U root -u root -N

Task: view the processes run by user Vivek

# ps -u vivek

Task: Top Command

The top command provides a Dynamic Real-Time View of the running system. Enter top in the command prompt line:

# top

Output:

Figure 1: TOP command: Display Linux tasks

Press Q to exit, and press h to enter help.

Task: displays the process tree.

Pstree displays running processes in a tree. The root node of the tree is PID or init. If the user name is specified, the process tree uses the processes owned by the user as the root node.

$ pstree

Output example:

Figure 2: pstree-display process tree

Task: print the process tree using PS

# ps -ejH# ps axjf

Task: Obtain thread Information

Enter the following command:

# ps -eLf# ps axms

Task: Obtain security information

Enter the following command:

# ps -eo euser,ruser,suser,fuser,f,comm,label# ps axZ# ps -eM

Task: Save process snapshots to files

Enter the following command:

# top -b -n1 > /tmp/process.log

You can also send the result to yourself by email:

# top -b -n1 | mail -s 'Process snapshot' you@example.com

Task: Search for processes

Use the pgrep command. Pgrep can find the currently running process and list the qualified process IDs. For example, display the Firefox process ID:

$ pgrep firefox

The following command displays the process named sshd and whose owner is root.

$ pgrep -u root sshd

Say hello to htop and atop

Htop is an interactive process viewing tool similar to top, but it can scroll vertically and horizontally to view all processes and their command lines. You do not need to enter a PID for process-related operations (killing, renicing. To install htop, run the following command:

# apt-get install htop

Or

# yum install htop

Enter htop in the command prompt line:

# htop

Output example:

Figure 3: htop-interactive Linux/Unix process viewer

Atop Tool

Atop is an interactive monitoring tool used to view Linux system loads. It shows the usage of key hardware resources (from the performance perspective) at the system level, such as CPU, memory, hard disk, and network.

It can also display the specific process load based on the CPU and memory load at the process level. If the kernel patch has been installed, it can display the hard disk and network load of each process. Run the following command to start atop:

# atop

Output example:

Figure 4: At computing's System & Process Monitor

Link: http://hi.baidu.com/imlidapeng/blog/item/4ef37d634b58b957eaf8f83d.html

Added to favorites!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.