Site icon LinuxCommands.site

linux ps command and ps examples

Linux ps command is an abbreviation of Process Status.

The linux ps command is used to list those processes currently running on the system.

The ps command lists the snapshots of the current processes, that is, the processes at the moment when the ps command is executed.

If you want to dynamically display the process information, you can use the linux top command.

To monitor and control processes, you must understand the state of the current process.

The Linux process has five states:

Syntax

ylspirit@ubuntu:~$ ps [options]

Common command parameters

PS has a lot of parameters, only a few commonly used parameters are listed here and the meaning is roughly introduced.

-A     Select all processes.  Identical to -e.
-a     Select all processes except both session leaders and processes not associated with a terminal.
-e     Identical to -A.
-u     Select by effective user ID  or name. 
-f     Shows the relationship between processes.
-o     Specify user-defined format.
-au    Shows more detailed information.
-aux   Shows all processes that contain other users.

Example

1. To see every process on the system

ylspirit@ubuntu:~$ ps -e | head -15
ylspirit@ubuntu:~$ ps -ef | head -15

2. To see every process on the system

ylspirit@ubuntu:~$ ps ax | head -15

ylspirit@ubuntu:~$ ps au | head -15
ylspirit@ubuntu:~$ ps aux | head -15

3. To see every process with a user-defined format:

ylspirit@ubuntu:~$ ps -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm | head -15

4. Print only the name of PID 1:

ylspirit@ubuntu:~$ ps -q 1 -o pid,tid,comm

More about linux commands:Linux Commands Tutorial

Exit mobile version