In this guide, we will be showing you how to use the ps command on a Linux system.
“ps” stands for process status and is a powerful tool that provides information about processes on your Linux system.
The ps command allows you to list the status of processes running on your system easily. By default, this command will limit its results to the current user and the current terminal session.
Using this, you can see the various information about your processes, including their ID, priority, memory usage, CPU usage, and more.
It is a solid alternative to other commands that provide information about running processes such as the top command.
Over the following few sections, we will explore how to use the ps command on your Linux system.
Table of Contents
- Syntax of the ps Command on Linux
- Basic Usage of the ps Command on Linux
- Full Format Listing from the ps command
- Retrieving the Long Format from the ps Command
- Display All Processes using ps
- Select Processes for a Specific User
- Select Processes by their Group ID
- Selecting Processes Based on Their Command Name
- Using the ps Command to View Processes by ID
- Viewing Processes Started By a Specific Terminal
Syntax of the ps Command on Linux
The syntax for the ps command is straightforward thanks to it being entirely controlled through its options parameter.
Below is the syntax you will need to follow when using the ps utility.
[OPTIONS]” parameter allows you to control the results of the ps command. For example, you can easily select the processes you get information from and control what information is returned to you.
You do not have to use the “
[OPTIONS]” parameter to use this utility. By default, it will provide some basic information about processes belonging to the current user and were run within the current terminal session.
Basic Usage of the ps Command on Linux
The simplest way to use the ps command is not to utilize any options when running it.
When used this way, the utility will only search for processes belonging to the user that ran the command. Additionally, it will limit itself to processes that were started within the current terminal session.
By default, the tool will only provide simple information that we will explore shortly.
Running this tool within a fresh terminal will return a minimal result, as shown below.
PID TTY TIME CMD 4767 pts/1 00:00:00 bash 8933 pts/1 00:00:00 ps
Headers from the ps Command
Now that we know what data this command returns let us quickly explore each value.
PID– This is the process ID given to the process when it was started.
You can use this ID for various tasks, including killing the process or changing its nice value.
TTY– This value represents the terminal used to initiate this process.
TIME– Using this value, you can tell how much CPU time this process has consumed since it first started running.
CMD– The final value represents the command used to start this process.
Full Format Listing from the ps command
The ps command offers a few different options to control the output format. One of these options is called the “full format listing”.
To utilize the full format option, you need to use the “
-f” option. The command also offers an “extended” version of the option by using “
Syntax for Displaying the Full Format Listing
The syntax for displaying the full format listing is shown below.
After using the command like this, you will end up with a result similar to what we have shown below.
UID PID PPID C STIME TTY TIME CMD pi 4730 4729 0 Feb07 pts/0 00:00:00 -bash pi 11211 4730 0 Feb10 pts/0 00:00:00 nano test.txt pi 14018 4730 0 04:38 pts/0 00:00:00 ps -f
Syntax for Displaying the Extended Full Format Listing
The syntax for displaying the extended full format listing is displayed below.
If you run the command above, you will get additional option as what we have displayed below.
UID PID PPID C SZ RSS PSR STIME TTY TIME CMD pi 4730 4729 0 2149 3804 0 Feb07 pts/0 00:00:00 -bash pi 11211 4730 0 2282 3904 0 Feb10 pts/0 00:00:00 nano test.txt pi 14019 4730 0 2715 2576 1 04:39 pts/0 00:00:00 ps -F
Full Format Listing Headers from the ps Command
Below is a list of the headings that you will find after using the full format option with the ps command.
UID– The user that started this process. This value will be shown as the user’s name.
PID– Value representing the unique process ID. You can use this ID to interact with the process.
PPID– This is the ID belonging to the parent process. The parent process is the one that initiated this process.
C– The amount of CPU that this process is currently consuming.
STIME– The time the process was started on the current system.
If the process started in a different year to when you ran the ps command, this option would display the year using the format “
YYYY“. For example, “
If the process was not started on the current day, it would be displayed in the “
MmmDD” format. So, for example, the result would appear as “
If the process was started the same day as when you executed ps it would use the format “
HH:MM“. For example, a valid output is shown as “
TTY– The terminal that was used when starting this process.
TIME– The amount of CPU time this process has consumed since it began running.
CMD– The command that was used to start this process.
Using the “extended” version of the full format option, you will get these additional columns.
SZ– The size in physical pages of the core image of the process. This includes text, data, stack space, and more.
RSS-The resident set size is the total amount of non-swapped physical memory used by the process. This value is displayed in kilobytes.
PSR– The processor that this process is currently assigned to.
Retrieving the Long Format from the ps Command
An additional option that you can use to provide more information from the ps command is the long format option. The long format provides a few different headers to what is provided by the “full format”.
To provide more data about the running processes, you can utilize the long format option “
-l” when running the command.
After running this command, you will see that you are greeted with a considerable amount more data.
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD 0 S 1000 4730 4729 0 80 0 - 2149 do_wai pts/0 00:00:00 bash 0 R 1000 9114 4730 0 80 0 - 2682 - pts/0 00:00:00 ps
Headers from the ps Command Using the Long Option
Below is a list of the headers displayed when using the long option. The descriptions here should help you understand what each column is showing.
F– The sum of all flags that have been set for this process.
Below are two possible flags that can be set.
1– Forked but didn’t execute
4– Used super-user privileges
S– The code shows the status of the process.
Below is a list of the potential status codes that can be shown for a process.
D– Uninterruptible sleep. This status usually means it’s waiting on IO to complete.
I– Idle kernel thread
R– Running or runnable
S– Interruptible sleep
T– Stopped by a job control signal
t– Stopped by debugger during the tracing
W– Paging (Only valid on kernels older than 2.6.xx)
X– Process is dead
Z– Zombie process, terminated but has not yet been removed by the parent process
UID– Unique ID of the user that started this process
PID– The unique ID that is used to identify this specific process on the system.
PPID– This value represents the parent processes unique ID. This is the process that launched the current process.
C– CPU Usage of the process when this command was run.
PRI– Priority of the process. A higher value indicates a lower priority. A lower value represents a higher priority.
Linux’s scheduler utilizes this to know how to handle this process.
NI– The nice value that has been set for this process. This value is used to adjust the priority
ADDR– The memory address of the process.
SZ– This value shows the amount of virtual memory this process is using.
WCHAN– If the process is sleeping, this will be the name of the kernel function in which it is sleep.
A hyphen (“
-“) will be displayed if the process is currently running.
The command will show an asterisk (“
*“) will be shown in the terminal if the process is multi-threaded and displaying threads is disabled.
TTY– The terminal that is in control of this process, or the one used to start it.
TIME– The amount of CPU time this process has consumed since it began running.
CMD– The command that was used to start up this process.
Display All Processes using ps
By default, the ps command will only print processes belonging to the calling user and that specific terminal session.
This tool can also print information about all running processes using the “
-A” or “
Below is an example of what this command can return. Every process that is currently running on your device will be listed.
By default, this list of processes will be ordered by their process ID.
PID TTY TIME CMD 1 ? 00:00:26 systemd 2 ? 00:00:02 kthreadd 3 ? 00:00:00 rcu_gp 4 ? 00:00:00 rcu_par_gp 8 ? 00:00:00 mm_percpu_wq 9 ? 00:00:00 rcu_tasks_rude_ 10 ? 00:00:00 rcu_tasks_trace 11 ? 00:00:56 ksoftirqd/0 12 ? 00:08:39 rcu_sched 13 ? 00:00:00 migration/0
Select Processes for a Specific User using the ps Command
The ps command allows you to select the user’s processes that you want to list. This utility breaks this down into two possible lists, each using a different option to reference.
- First, you can select processes that have your specified effective user ID (EUID) or username.
The effective user id is the user whose file access permissions are being utilized by the process. This can differ from the user that started the process.
You need to use the “
-u USER” option to specify the effective user id, as shown below. The user value can either be their ID or their username.
ps -u USER
- Secondly, you can select processes by specifying their real user ID (RUID), or username.
The real user ID is the user’s ID that started the process. This can differ from the user whose permissions the process is currently using.
To search using the real user ID, you need to use the option “-
u USER“. You can either use the user’s ID or their username.
ps -U USER
Example of Selecting Processes by their Effective User ID
For our first example, we will be using the ps command to find processes with the effective user id set to “
We need to use the following command, using the “
-u” while referencing the user id of “
1000” after it.
ps -u 1000
Alternatively, we can also use the user’s name to achieve the same thing without utilizing its ID.
ps -u pi
After running either one of these commands, you will end up with a list of every process using our specific user for its file access permissions.
PID TTY TIME CMD 774 ? 00:00:00 systemd 775 ? 00:00:00 (sd-pam) 844 ? 00:00:00 pipewire 845 ? 00:00:00 pulseaudio 850 tty1 00:00:00 bash 851 ? 00:00:00 lxsession 862 ? 00:00:00 dbus-daemon 876 ? 00:00:00 pipewire-media- 923 ? 00:00:08 ssh-agent 996 ? 00:00:00 gvfsd 1001 ? 00:00:00 gvfsd-fuse
Example of Selecting Processes by their Real User ID
For our second example, we will show you how to use the ps command to select processes with a real user id of “
To achieve this, we will use the “
-U” option, followed by user id “
ps -U 1000
When selecting by the effective user id, you can also utilize the user’s name instead of their ID.
ps -U pi
Below is an example of the results you would get after running a command similar to this one. All processes listed will have been started by the user you specified.
PID TTY TIME CMD 1098 ? 00:00:00 gvfs-goa-volume 1102 ? 00:00:00 gvfs-mtp-volume 1106 ? 00:00:00 gvfs-gphoto2-vo 1110 ? 00:01:15 gvfs-afc-volume 1116 ? 00:00:00 gvfsd-trash 4729 ? 00:00:43 sshd 4730 pts/0 00:00:00 bash
Select Processes by their Group ID using the ps Command
The ps command allows you to select processes by an associated group ID or name. The utility separates this into two categories: the real group id, and the other the effective group id.
- The effective group id (EGID) reflects the group that the process uses for its file access permissions. You can specify the group’s ID or name when using this option.
You can select processes based on their effective group id by using the “
-g GROUP” option.
ps -g GROUP
- The real group id (RGID) represents the group of the user that started the process. This option supports using the ID or group name.
To select all processes based on the real group id, you must use the “
-G GROUP” option.
pg -G GROUP
Example of Selecting Processes Based on Their Effective Group ID
For this example, we will use the ps command to show all processes with the effective group id of “
We need to use “
-g 1000” as our option to select processes using that group for its file access permissions.
ps -g 1000
As mentioned earlier, you can also reference the group name instead of using its ID. In our case, this group name is “
pg -G pi
Below is an example of the result you will get from using either one of these commands. All of the processes listed used our group for its file access permissions.
PID TTY TIME CMD 654 tty1 00:00:00 login 774 ? 00:00:00 systemd 775 ? 00:00:00 (sd-pam) 844 ? 00:00:00 pipewire 845 ? 00:00:00 pulseaudio
Example of Selecting Processes Based on Their Real Group ID
For this example, we will select all processes with a real group id of “
We will need to use the option “
-G 1000” alongside the ps command.
ps -G 1000
Additionally, we can reference this same group by using its name, which is “
ps -G pi
You can see the results we got from running these examples on our Linux device in the box below. These processes were all started by our “
PID TTY TIME CMD 1016 ? 00:11:24 lxpanel 1018 ? 00:00:01 pcmanfm 1027 ? 00:00:00 ssh-agent 1029 ? 00:00:00 sh 1031 ? 00:00:00 agent
Selecting Processes Based on Their Command Name
The ps command allows you to select processes based off their command name. The command name isn’t the full command, but the portion used to start the program itself.
For example, if you run the command “
nano example.txt“, the command name would be “
To list processes based on the command name, you will need to use the “
-C CMDNAME” option. This option supports multiple command names. Each one needs to be separated by a comma (“
ps -C CMDNAME
Example of Selecting a Process Based on Command Name
For this example, we will list all processes running on our device that were launched using “
sshd“. This program is the daemon for our SSH connection to see multiple processes after running the following command.
To search for “
sshd” we need to use the “
-C” option, followed by “
ps -C sshd
Below you can see the process list found for the “
PID TTY TIME CMD 637 ? 00:00:00 sshd 4721 ? 00:00:03 sshd 4723 ? 00:00:00 sshd 4729 ? 00:00:44 sshd 4751 ? 00:00:00 sshd 4758 ? 00:00:03 sshd 4760 ? 00:00:00 sshd 4766 ? 00:00:15 sshd 4788 ? 00:00:00 sshd
Using the ps Command to View Processes by ID
The ps command allows you to fine-tune its selection by specifying either the process ID or the parent process ID.
This functionality is helpful if you already know the ID you are looking for and want to find additional information about that process.
To narrow the ps command down to a specific process ID (PID), you need to use the “
-p PID” option.
ps -p PID
You can also select processes by their parent process id (PPID). This option is slightly different and requires you to use “
ps --ppid PID
You can reference multiple process IDs by separating each value by a comma “
Example of Selecting Processes by their ID
We will show you a couple of different ways to select a process by its ID in the following examples. We will also show you how to utilize multiple IDs within the command.
Selecting a Single Process using an ID
In this example, we will use the ps command to select a process with the id of “
11211“. Using the option this way will only get information of a single process.
We need to use the “
-p” option followed by the id “
ps -p 11211
After running this command, you will get information about that particular process.
PID TTY TIME CMD 11211 pts/0 00:00:00 nano
Selecting using Multiple Process IDs
You can also reference multiple process IDs by separating each value by a comma. For example, if we wanted to check both “
11211” and “
4730” we could use the following command.
ps -p 11211,4730
From the result, you can tell we have now successfully gotten information about both processes.
PID TTY TIME CMD 4730 pts/0 00:00:00 bash 11211 pts/0 00:00:00 nano
Example of Selecting Processes Using the Parent Process ID
Selecting using the parent process ID allows you to list all processes that a single process has started.
Below we will show you how to do this for single and multiple parent process IDs.
Selecting Processes Using a Single Parent Process IDs
For our first example, let us list all processes with a parent ID of “
4730“. This ID belongs to our bash terminal, so everything we have started from it will be listed using this command.
We need to use “
--ppid 4730” as the option for the ps command.
ps --ppid 4730
Below is an example of the data that we got in our terminal after running the command above.
PID TTY TIME CMD 11211 pts/0 00:00:00 nano 11259 pts/0 00:00:00 ps
Selecting Processes using Multiple Parent Process IDs
For our second example, we will use the ps command to list all processes with a parent ID of “
4730” or “
4729“. As we are using multiple parent process IDs, we only need to separate them using a comma (
ps --ppid 4730,4729
After using the command above, you can see that we received an additional process thanks to the additional parent ID.
PID TTY TIME CMD 4730 pts/0 00:00:00 bash 11211 pts/0 00:00:00 nano 11273 pts/0 00:00:00 ps
Viewing Processes Started By a Specific Terminal
The ps command features an option that allows you to select all processes started by a specific terminal.
To list processes based on the tty that started them, you need to use the “
-t TTY” option. With this option, you need to specify the terminal ID you want to get the processes from.
ps -t TTY
Example of Listing Processes by Terminal using the ps Command
For this example, we will list all processes started under the “
All we need to do is use the “
-t” option, followed by the terminal we want to look for, which in our case is “
ps -t pts/0
Below you can see an example of the data you would get by listing processes by the starting terminal.
PID TTY TIME CMD 4730 pts/0 00:00:00 bash 11211 pts/0 00:00:00 nano 13926 pts/0 00:00:00 ps
This guide will teach you how to use the ps command on a Linux-based operating system.
The ps command allows you to easily get information about processes on your device. It provides a snapshot of those processes at that point in time, unlike the top command that provides constant updates.
If you have had issues with using this utility, please comment below.
Additionally, check out our Linux command guides and our Linux tutorials.