The Linux “ps” Command Examples

7

The “ps” command in Linux is an abbreviation of “process status”. It is used to get information about the processes running within your system. The output of this command can vary depending upon the parameters used with it. However, in this article, we intend to teach you the basics of using the “ps” command in Linux with the help of a few examples.

General Syntax of the “ps” Command in Linux

The general syntax of the “ps” command in Linux is given below:

There are specific parameters used with the “ps” command found in its “help” manual. However, this command can also be executed independently without any errors.

Help Manual of the “ps” Command in Linux

If you want to learn about the correct usage of the “ps” command before heading on to its examples, then you can access its “help” manual with the following command:

You can see the “help” manual of the “ps” command in the image given below:

Examples of Using the “ps” Command in Linux

Now, we will be sharing with you a few examples of using the “ps” command in Linux.

Example 1: Display the Processes Running in the Current Shell
If you wish to display the processes that are running in the current shell, then you should execute the “ps” command without any parameters as follows:

The processes running in the current shell of our Linux system are shown in the image below:

Example 2: Display All the Currently Running Processes
You can also list down all the currently running processes of your Linux system with the following command:

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

Example 3: Display All the Processes Associated with the Current Terminal
There are certain processes that are associated with the current terminal session. If you want to take a look at all such processes of your current terminal session, then you can execute the following command:

All the processes associated with our current terminal session are shown in the image below:

Example 4: Display All the Processes Associated with a Particular User
You can even list down all the processes related to a particular user of your Linux system. To do so, you can execute the following command:

Here, you can replace UserName with the name of the user whose associated processes you want to list down. For example, we have replaced it with “kbuzdar” in our case.

All the processes associated with the specified user of our Linux system are shown in the image below:

Example 5: Display All the Processes Associated with a Particular User Group
Similar to the example above, some processes are associated with a particular user group of your Linux system. You can even list down these processes with the execution of the following command:

Here, you can replace UserGroupName with the name of the user group whose associated processes you want to list down. For example, we have replaced it with “root” in our case.

All the processes associated with the specified user group of our Linux system are shown in the image below:

Conclusion

By going through today’s guide, you will be able to get a basic understanding of the usage of the “ps” command in Linux. Once you manage to learn the basics, you can quickly master the usage of this command by using it repeatedly while performing your routine tasks in the Linux environment.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More