In this article we are going to shows how to use ps command in Linux. If you want to learn about ps command in Linux with Examples then this post is ideal for you.
Linux is a powerful multi-tasking and multi-user operating system. It allows multiple processes to operate simultaneously without any interfering with each other.
A process is an running instance of a program and it is a most important fundamental concept of the Linux operating system.
In the Linux, ps is a command line utility that is used to viewing information about running processes. It is list the currently running processes and their PIDs with some other important information.
How to Use ps command in Linux
In the Linux, the basic syntax of the ps command is show as below:
$ ps [OPTIONS]
The ps
command provides several different types of options for manipulating the output:
- UNIX style options, preceded by a single dash.
- BSD style options, used without a dash.
- GNU long options, preceded by two dashes.
When you run the ps
command without any options then it will display four columns of information for minimum two running processes.
$ ps
Output
PID TTY TIME CMD
5502 pts/0 00:00:00 bash
5512 pts/0 00:00:00 ps
The ps command accepts many options that are used to display a specific group of processes and different information about the process.
Where,
PID – It is the unique process ID.
TTY – It is the name of the controlling terminal for the process.
TIME – CPU time of the process in minutes and seconds.
CMD – Name of the command that was used to launched the process.
The ps command is most frequently used with the below combination of options:
BSD Form
$ ps aux
In the above command, we use combination of three options at once:
a
option is used to display the processes of all users.u
(user-oriented format) option provides detailed information of the processes.- x option used to list the processes without a controlling terminal.
The command above will display output as show below:
Output
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.6 88716 7614 ? Ss Feb25 0:01 /sbin/init
root 2 0.0 0.0 0 0 ? S Feb25 0:00 [kthreadd]
...
Use the -f
option to display a tree view of parent to child processes:
$ ps auxf
UNIX Form
$ ps -ef
In the above command, we use combination of two options at once:
-e option
used to display all processes.-f
(full-format listing) option provides detailed information of the processes.
The command above will display output as show below:
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 Feb25 ? 00:00:05 /sbin/init
root 2 0 0 Feb25 ? 00:00:00 [kthreadd]
Run the command below to display only the processes running as a specific user(studiesonline):
ps -f -U studiesonline -u studiesonline
Specific Format
Use o option to show specified columns. For an example, if you want to display only PID
and PPID
, run command below:
$ ps -efo pid,ppid
$ ps auxo pid,ppid
That’s all
If you face any error and issue in above steps , please use comment box below to report.
If our tutorials helped you, please consider buying us a coffee. We appreciate your support!
Thank you for your support.