What two commands will display the status of processes on a Linux system Select one answer?

In this guide, we will be showing you how to use the ps command on a Linux system.

What two commands will display the status of processes on a Linux system Select one answer?

“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
    • Headers from the ps Command
  • Full Format Listing from the ps command
    • Syntax for Displaying the Full Format Listing
    • Syntax for Displaying the Extended Full Format Listing
    • Full Format Listing Headers
  • Retrieving the Long Format from the ps Command
    • Headers from the Long Option
  • Display All Processes using ps
  • Select Processes for a Specific User
    • Example of Selecting Processes by their Effective User ID
    • Example of Selecting Processes by their Real User ID
  • Select Processes by their Group ID
    • Example of Selecting Processes Based on Their Effective Group ID
    • Example of Selecting Processes Based on Their Real Group ID
  • Selecting Processes Based on Their Command Name
    • Example of Selecting a Process Based on Command Name
  • Using the ps Command to View Processes by ID
    • Example of Selecting Processes by their ID
      • Selecting a Single Process using an ID
      • Selecting using Multiple Process IDs
    • Example of Selecting Processes Using the Parent Process ID
      • Selecting Processes Using a Single Parent Process IDs
      • Selecting Processes Using Multiple Parent Process IDs
  • Viewing Processes Started By a Specific Terminal
    • Example of Listing Processes by Terminal
  • Conclusion

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.

The “[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.

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 “-F“.

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.

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.

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, “2022“.

    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 “Feb07“.

    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 “04:39“.

  • 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.

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 “-e” option.

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.

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.

  • 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.

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 “1000“.

We need to use the following command, using the “-u” while referencing the user id of “1000” after it.

Alternatively, we can also use the user’s name to achieve the same thing without utilizing its ID.

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.

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 “1000“.

To achieve this, we will use the “-U” option, followed by user id “1000“.

When selecting by the effective user id, you can also utilize the user’s name instead of their ID.

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.

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.

  • 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.

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 “1000“.

We need to use “-g 1000” as our option to select processes using that group for its file access permissions.

As mentioned earlier, you can also reference the group name instead of using its ID. In our case, this group name is “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.

Example of Selecting Processes Based on Their Real Group ID

For this example, we will select all processes with a real group id of “1000“.

We will need to use the option “-G 1000” alongside the ps command.


Additionally, we can reference this same group by using its name, which is “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 “pi” user.

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 “nano“.

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 (“,“)

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 “sshd“.

Below you can see the process list found for the “sshd” process.

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.

You can also select processes by their parent process id (PPID). This option is slightly different and requires you to use “--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 “11211“.

After running this command, you will get information about that particular process.

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.

From the result, you can tell we have now successfully gotten information about both processes.

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.

Below is an example of the data that we got in our terminal after running the command above.

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 (,).

After using the command above, you can see that we received an additional process thanks to the additional parent ID.

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.

Example of Listing Processes by Terminal using the ps Command

For this example, we will list all processes started under the “pts/0” terminal.

All we need to do is use the “-t” option, followed by the terminal we want to look for, which in our case is “pts/0“.

Below you can see an example of the data you would get by listing processes by the starting terminal.

Conclusion

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.

Weekly Updates Straight To Your Inbox

Receive our Raspberry Pi projects, coding tutorials, Linux guides and more!

What command display the status of processes on a Linux system?

You can list running processes using the ps command (ps means process status). The ps command displays your currently running processes in real-time. This will display the process for the current shell with four columns: PID returns the unique process ID.

What is the command to view processes in Linux?

To list processes in Linux, use one of the three commands: ps, top or htop. Ps command provides static snapshot of all processes, while top and htop sorts by CPU usage.

Which command is used to know the status of process?

You can use the ps command to find out which processes are running and display information about those processes. The ps command has several flags that enable you to specify which processes to list and what information to display about each process.

What command displays a list of processes running on a system?

Use the ps command to list all the processes on a system.