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 .
Introduction to ps Command
The ps command shows details of a selection of the running processes. If we wish repetitive selection updates and displayed information, we can use the top command rather.
This version of the ps command accepts many types of options, which are mentioned below:
Different types of options may freely be mixed, but clashes can occur. There are a few synonymous options, functionally identical, because of several ps implementations and standards that the ps command is compatible with.
Note: The ps -aux command is different from the ps aux command. The UNIX and POSIX standards need that the ps -aux command print every process owned by any user named x and print every process that will be chosen by the -a flag.
Implementations of ps Command
KolibriOS contains the ps command implementation. Also, this command has been ported to IBM i OS. The ps command is a predefined command alias in Windows PowerShell for the Get-Process cmdlet, which essentially serves a similar purpose.
Environment Variables of ps Command
Below environment variables will affect the ps execution:
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.
Next TopicLinux Shutdown Command