ps command in linux

ps command in Linux / Ubuntu

ps command in Linux / Ubuntu

ps command in Linux / Ubuntu, which lets us to view the current running processes.its is also usefull in killing a process or to view which applications other users are running.

ps stands as abbreviation for “Process Status”


ps [options]

1. Simple process selection :
Shows the processes for the current shell

ps command in linux / ubuntu | ps

PID the unique process ID
TTY terminal type that the user is logged into
TIME amount of CPU in minutes and seconds that the process has been running
CMD name of the command that launched the process

Also please note TIME 00:00:00 means the total accumulated CPU utilization time for any process and 00:00:00 indicates no CPU time has been given by the kernel till now.

2. List All Process

the -ax options in order to list all processes.

ps command in linux / ubuntu | ps -ef


-e to display all the processes.
-f to display full format listing.

In BSD we can use ps -aux

3. List Processes As Tree

This command will display parent and child tree like structure information of process.

ps command in linux / ubuntu | ps -A --forest

4. List Process Info

We will use -u option for this detailed information.

5. Show process by name or process id

ps command in linux / ubuntu | ps -C apache2

Here we will use -C parameter and process name for filter operation.

ps command in linux / ubuntu | ps -p

We will use the -p option and PID in order to filter.

Often ps is used with grep like ps -aux | grep command to get the list of process with the given command.

ps command in linux / ubuntu | ps -ef

The grep command helps you filter the results from the ps command.

6. How to list all processes for a user

-u option to display all the process used by user. This supports the user ID or name.

ps command in linux / ubuntu | ps -u

7. How to list all processes for a group

To list all processes by group use the -g option. This supports the group ID or name.

8. Display threads of a process

-L  will display the threads of the process. It will display all threads of a particular process.

Below command will display all the threads owned by the process with id 2048.

ps command in linux / ubuntu

Now Some Advance Usage of ps command

Now below command will search for processes by the name apache2 and construct a tree and display detailed information.

Turn ps into an realtime process viewer

The output on my desktop is something like this.

ps command in linux / ubuntu

The output would be updated every 1 second to refresh the stats. However do not think that this is similar to top.

How to search for an kill a process

To  kill a process first we need to find process id (PID) then using the kill command to terminate the process. In the following example ps is piped to grep


now we got pid of tomcat

You May Also Enjoy Reading This …