ps command (process status command) is used display list of running process on your linux system along with their PID’s (process identification numbers).
Syntax
ps
Running this command displays processes for current shell along with PID number, TTY (Terminal type), time and command.
Display all running processes
To display all running process use following command
Syntax
ps -A
OR
ps –e
Display all running processes with detailed information
To get a full list of running processes use the following command
Syntax
ps -ef
-e as we have already mentioned shows all running programs and –f will show full details.
User ID is the person who initiated the command. The PID is the process ID of the command and PPID is the parent process that started the command.
The C column shows the number of children of process. The STime is the start time for the process. The TTY is the terminal, the time is the amount of time it took to run and command is the command which was run.
Display processes by real group ID or name
To display all processes owned by a group (real group ID or name) use -G or -g switch
Syntax
To display process owned by name of group
ps -G group_name
and
To display process on basis of Group ID number
ps -u group_ID
Display processes by Process ID
Process list can be displayed by using process ID details, switch used in this case is -p.
Syntax
ps -p process_id
Display processes by Process ID list
Process list can also be displayed by using list process ID details, switch used in this case is -p. All process ID’s are separated by comma’s
Syntax
ps -p process_id_list
Find process name by its process ID
To find process name using its ID use following command
Syntax
ps -p [process_ID] -o comm=
Display processes by terminal
To display process by terminal details using switch -t
Syntax
ps -t [terminal_details]
Display processes child and parent by process name
A process can be selected using -C switch, it will also display all its child process
Syntax
ps -C [process_name}
Display processes tree
Process tree displays how processes are linked to each other. Parent of a process is either a process with given PID or it will be init.
Syntax
ps -forest
and
In case you want to view process tree for a particular process use command
ps -f -forest -C apache