You can use the PS command. It can display information about the current running process, including the PID of the process. Both Linux and UNIX support the PS command, which displays information about all running processes.
The PS command can provide a snapshot of the current process. If you want the status to refresh automatically, you can use the top command.
PS command
Enter the following PS command to display all running processes:
which
-A: Show All processes
A: Show all processes that include other users in the terminal
X: Show the process without control terminal
Task: View each process in the system.
tasks: Viewing non-root running processes
1 |
# ps -U root -u root -N |
Task: View the process that the user Vivek runs
Task: Top command
The top command provides a dynamic, real-time view of the running system. At the command prompt, enter top:
Output:
Press Q to exit and press H to enter help.
Task: Displays a tree view of the process.
Pstree displays the running process in a tree-like way. The root node of the tree is PID or init. If a user name is specified, the process tree takes the process owned by the user as the root node.
Output Example:
Task: Using the PS print process tree
Task: Getting thread information
Enter the following command:
# ps-elf# PS AXMS
Task: Get security information
Enter the following command:
123 |
# ps -eo euser,ruser,suser,fuser,f,comm,label # ps axZ # ps -eM |
Task: Save a process snapshot to a file
Enter the following command:
1 |
# top -b -n1 > /tmp/process.log |
You can also send your results to yourself via email:
1 |
# top -b -n1 | mail -s ‘Process snapshot‘ you @example .com |
123 |
任务:查找进程 使用pgrep命令。pgrep能查找当前正在运行的进程并列出符合条件的进程ID。例如显示firefox的进程ID: |
The following command displays the process named sshd and owner-root.
123 |
向htop和atop说hello htop是一个类似top的交互式进程查看工具,但是可以垂直和水平滚动来查看所有进程和他们的命令行。进程的相关操作(killing,renicing)不需要输入PID。要安装htop输入命令: |
Or
# yum Install Htop
At the command prompt, enter Htop:
Output Example:
Atop tools
Atop is an interactive monitoring tool for viewing the load on Linux systems. It demonstrates the use of critical hardware resources (from a performance perspective) at the system level, such as CPUs, memory, hard disks, and networks.
It can also show which process is causing a specific load based on the CPU and memory load at the process level, and if a kernel patch is installed, the hard disk and network load for each process can be displayed. Enter the following command to start atop:
Output Example:
Original link: http://hi.baidu.com/imlidapeng/blog/item/4ef37d634b58b957eaf8f83
How to view all running processes in a Linux system