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 LinuxThe 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 “ You
do not have to use the “ Basic Usage of the ps Command on LinuxThe 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 CommandNow that we know what data this command returns let us quickly explore each value.
Full Format Listing from the ps commandThe 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 “ Syntax for Displaying the Full Format ListingThe 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 ListingThe 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 CommandBelow is a list of the headings that you will find after using the full format option with the ps command.
Using the “extended” version of the full format option, you will get these additional columns.
Retrieving the Long Format from the ps CommandAn 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 “ 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 OptionBelow is a list of the headers displayed when using the long option. The descriptions here should help you understand what each column is showing.
Display All Processes using psBy 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 “ 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 CommandThe 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.
Example of Selecting Processes by their Effective User IDFor 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 “ 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 IDFor 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 “ 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 CommandThe 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.
Example of Selecting Processes Based on Their Effective Group IDFor this example, we will use the ps command to show all processes with the effective group id of “ We need to use “ As mentioned earlier, you can also reference the group name instead of using its ID. In our case, this group name is
“ 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 IDFor this example, we will select all processes with a real group id of “ We will need to use the option “ Additionally, we can reference this same group by using its name, which is “ 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 “ Selecting Processes Based on Their Command NameThe 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 “ To list processes based on the command name, you will need to use the “ Example of Selecting a Process Based on Command NameFor this example, we will list all
processes running on our device that were launched using “ To search for “ Below you can see the process list found for the “ Using the ps Command to View Processes by IDThe 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 “ You can also select processes by their parent process id (PPID). This option is slightly different and requires you to use “ You
can reference multiple process IDs by separating each value by a comma “ Example of Selecting Processes by their IDWe 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 IDIn this example, we will use the ps command
to select a process with the id of “ We need to use the “ After running this command, you will get information about that particular process. Selecting using Multiple Process IDsYou can also reference multiple process IDs by separating each value by a comma. For example, if we wanted to
check both “ From the result, you can tell we have now successfully gotten information about both processes. Example of Selecting Processes Using the Parent Process IDSelecting 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 IDsFor our first example, let us list all processes with a parent ID of “ We need to use “ Below is an example of the data that we got in our terminal after running the command above. Selecting Processes using Multiple Parent Process IDsFor our second example, we will use the ps command to list all processes with a parent ID of “ 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 TerminalThe 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 “ Example of Listing Processes by Terminal using the ps CommandFor this example, we will list all processes started under the “ All we need to do is use the “ Below you can see an example of the data you would get by listing processes by the starting terminal. ConclusionThis 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.
|