How to use the Linux ps command to get an overview of running processes
The ps command for Linux will give you an overview of all the processes currently running on your system. The command also has a range of options so that you can get a more specific list.
What is the Linux ps command?
If your system is running particularly slowly or you’re experiencing other issues, the Linux command ps can be a great help. This will give you a list of all processes that are currently running on your system. In this case ‘ps’ stands for ‘process status’. The command will give you the name of the process alongside the process identification number (PID), the CPU time it’s taking as well as the terminal as standard. All this information is useful for you to get an overview and quickly identify problems. If you want to investigate specific processes, we recommend using the pgrep command. The ps command works on all Linux distributions such as Ubuntu.
How does the ps command work?
If you enter the ps command without using any options, you will be given a list of all processes which were started from the current shell. Other processes will not be shown in this case. If you want to see them as well, read on further down. The list is very easy to view and gives you some initial reference criteria such as how well or poorly the current processes are running.
What does the ps syntax look like?
The Linux ps command’s syntax is very easy to use and looks as follows:
ps [Options]
shellIf you run the command, it will give you a list of all the processes that are currently running.
What are the options in Linux ps?
The ps command has different options you can use. Those in the UNIX format can be added by using a simple hyphen and can be grouped together. BSD options don’t need the hyphen and can also be grouped together. GNU options are initiated using two hyphens. Among the most important options include:
- -A: Takes all processes being run on the system into account.
- -a: Also takes all processes into account, except those that are not linked to the terminal. On top of this sessions leaders are excluded.
- -C [Process]: This only displays processes that are listed under [Processes].
- -d: Includes all processes except session leaders.
- -e: Identical to -A.
- -f: You can use this option to get a more detailed list of the individual processes.
- r: Only takes into account processes currently running.
- T: This will only take into account processes that are connected to the current terminal.
- x: You can use this option to limit the result to processes which belong to you or other users.
Examples of a ps command
To make it clearer how you can use Linux ps with the different options, here are a couple of examples:
$ ps -A
shellThis will show all the processes.
$ ps -ef
shellThis will give you more details about all processes.
$ ps -fC programm1, programm2, programm3
shellWith this example you will see more detailed information about certain programs.