ps Command in Linux/Unix with Examples
The ps command is used to view currently running processes on the system. It helps us to determine which process is doing what in our system, how much memory it is using, how much CPU space it occupies, user ID, command name, etc .
The ps command may display different results for different systems because it displays information about the currently running process of a system.
Look at the above snapshot, 4 columns are displayed as the output.
ps command supports 3 types of usage syntax style
Linux ps -ef and ps -aux
To display all currently running processes in full format on a system two types of commands are used.
e displays all the processes
f displays full format listing
Look at the above snapshot, it display all the running processes on our system.
Look at the above snapshot, this command filter the result by CPU or memory usage. It helps you in determining how much memory is used or how much CPU space is used by a process.
Linux ps -ax
This command display all the processes in a system. Here, a stands for all. It will display a long list of result.
Look at the above snapshot, it does not display information in full format but shows a list of all the processes running in the system.
Linux ps -u <username>
Option u displays the process for a specific user. You can also specify multiple usernames separated by a comma between them.
ps -f -u akki,sssit
Look at the above snapshot, it display the processes of akki and sssit with "ps -f -u akki,sssit" command.
Linux ps -C <command>
Option C display a list of processes with the mentioned command as argument.
Look at the above snapshot, it displays all the processes which has firefox in its command execution.
Linux ps -f -p <PID>
Each process is assigned with a specific Process ID number.
A process may have many sub process listed under it. Each of these sub process will also have its own PID number. So, a process will have its own PID number and may have a parent PID number.
Option p display list of the processes having the mentioned PID number.
Look at the above snapshot, it displays the processes with the mentioned PID numbers.
Linux ps -f --ppid <PPID>
As mentioned earlier, some process may have PPID along with PID number. All the sub processes having same PPID number may be listed by mentioning PPID number.
ps -f --ppid 1517
Look at the above snapshot, all the sub processes of PPID 1517 are listed here.