This article will show you how to list running processes in Linux using several tools. This will allow you to see what is running and how your system resources are being consumed.
It’s helpful to see what resources are in use by what process to diagnose slow systems. This information can be used to determine whether you need to purchase more memory (RAM), a faster processor, or whether an application or service on your computer is misconfigured and using more resources than it should.
What is a Process?
A process is an application running on your system. It could be a web browser that you can see running on your desktop, or it could be a file server running in the background that isn’t something with which you generally interact directly.
Processes consume resources – memory and processing time (as well as storage and networking resources if the application requires them), which they use to perform whatever task they were written to do.
The below commands list these running processes and the resources which they are using.
The ps Command
The ps (Process Status) lists the status of running processes (funnily enough). Run it with the default options by executing:
By default, ps will list processes for the current terminal session – it will not show processes from other sessions or other users other than the one currently logged in.
To view all running processes for user users on the system:
The aux option combines several options – a to show processes for all users, u to output additional info like CPU and memory usage, and x to list background processes not executed from the terminal.
You can view the full user manual for the ps command by running:
The top Command
The top command can be used to find resource-hungry processes – it provides an automatically updated display with processes in order of how much of the system resources they are using up.
To run it.
Rather than passing options to top, when top is running, you can press various keys on the keyboard to change how the data is displayed and sorted on the screen.
|c||Display the absolute path to the processes executable|
|d||Changes the refresh interval – the rate at which the top screen is updated|
|M||Sorts by memory usage|
|N||Sorts by PID (Process ID)|
|r||Changes the process priority|
|z||Displays process list in color|
Watch out! The above commands are case-sensitive.
Some of these commands may not be supported on your system if you are not running as root or using the sudo command.
You can view the full user manual for the top command by running:
The htop Command
htop is just like the top command, but it has some extra features to make it easier to use.
You can scroll around to view the full list or use the mouse to navigate.
htop may not be installed by default in your Linux distribution.
If you’re on Ubuntu, it can be quickly installed by running:
sudo apt install htop
…and most other Linux distributions should have htop available in their package repositories.
Once installed, simply run:
…to launch htop. Like top, it contains keyboard shortcuts to navigate, sort, and manage the running processes:
|F4||Filter processes by name|
|F5||Display tree view|
|F6||Sort processes by column|
|F7||Decrease process priority|
|F8||Increase process priority|
You can view the full user manual for the htop command by running: