Linux Commands

PS Command Linux

“The process status or the PS command in Linux is used for displaying the status of the different processes of a system. It includes the nature of these processes, their time of execution, PIDs, etc. However, the output of this command can easily be customized according to the needs by using the different options that are available. Therefore, in this article, we will be sharing with you a few examples of using the PS command in Linux.”

Using the PS Command in Linux

Before starting to use the process status command in Linux, we would like you to take a look at its help manual so that you can have an idea about the different options that we will be using in the examples below. The following command will help you in accessing the help manual of this command:

$ ps --help s

The help manual of the PS command in its simplest form is shown in the image below:

Now, we will walk you through some of the different usage scenarios of this command.

Example # 1: Using the PS Command Without Any Options

You can use the PS command independently, i.e., without any options. In this way, this command only displays the processes belonging to the current terminal. This command can be executed in the following manner:

$ ps

The processes belonging to our current terminal are shown in the image below:

Example # 2: Using the PS Command With the “-A” Option

If you want to list down all the processes of your system, then you should use the PS command in the following manner:

$ ps –A

The “-A” flag allows you to display all the processes on the terminal, as shown in the image below:

Example # 3: Using the PS Command With the “-d” Option

If you wish to display all the processes except for the session leaders, then you can execute the PS command as follows:

$ ps –d

All the processes of our system, except for the session leaders, are shown in the image below:

Example # 4: Using the PS Command With the “r” Option

Now, if you only wish to display the running processes on the terminal, then you will have to use the PS command as follows:

$ ps r

All the running processes of our Linux system are displayed in the image below:

Example # 5: Using the PS Command With the “T” Option

This method is an alternative to the first method that we discussed for displaying the processes belonging to the current terminal only. You just need to run the PS command in the following manner:

$ ps T

The “T” flag of the PS command restricts the output of this command to the processes belonging only to the current terminal, as shown in the image below:

Conclusion

We talked about the purpose of the PS command in this article, followed by a few examples to elaborate on its usage. Once you understand these examples well, it will be very easy for you to use the PS command on your Linux system.

Similar Posts