Examples on how to use PS COMMAND in Linux — The Linux GURUS
Linux has a number of processes running together without them being interfering with each other. So in order to administer a Linux system, we should also know how to effectively manage the Linux processes. There are many commands that help us accomplish that but none is as popular & widely used as ‘ps’.
PS command, ‘process status’, is used for checking & managing all the Linux processes. PS command in linux lists out all the processes that are currently running on the system. It will provide a list of processes along with their PIDs & some other information about processes as well.
Recommended Read: How to change timezone in Linux Also Read: Install EPEL repository on CentOS/RHEL 6, 7 & 8
Information about the processes is stored in virtual files in /proc, ps command process information from these files & provides us with the process information. In this tutorial, we will learn to use the ps command with the help of some examples.
PS command in Linux
List all processes
To get a list of all processes, use
The results will have process information in 4 columns i.e. PID- process id, TTY- terminal for user, TIME- time since the process is running, CMD- the command that launched the process.
These are other commands to get a list of all processes. To perform a full-listing of process, use
Get information for a specific process
To get information about a single process, we can filter the process with ‘grep’ command,
Get process information for the current user
To get the list of processes running under the currently logged in user, use
Get process information for another user
To get the list of processes running under another user, we can use the option ‘U’ with ps command,
Or we can also mention the UID/user id instead of the user name,
Get process information for a group
To the processes running under a group, we can use option ‘G’ followed by either group name or group id,
Get parent & child processes
To get list of all parent & child processes, use the following command,
Display processes running on a terminal
To get the list of all processes that are running on a particular terminal, we can use the following command,
Custom output for process command
If we only need some of the fields from the output of ps command, then we can use option ‘o’ to do so,
Now we will only get pid, cmd, user & etime in the output of ps command.
These were some of the examples for using ps command in Linux. There are plenty of other options that can be used with ps command also, to get the complete list of options available, we can use help,
We now end this tutorial on how to use ps command in Linux. Please do let us know if you have any questions, queries or suggestions using the comment box below.
If you think we have helped you or just want to support us, please consider these:-
TheLinuxGURUS are thankful for your continued support.
Originally published at https://thelinuxgurus.com on January 16, 2020.