When too many processes are running simultaneously in your Linux, you might want to stop or prioritize some of them. Read this article to find out how to list all the running processes!
Linux enables you to run multiple processes simultaneously. Sometimes, you might need to stop certain processes, modify their priority or move them to the background to free the resources of the system. To achieve this goal, you need to view the list of all your active processes and decide which of them you can temporarily sacrifice. From this article, you’ll get to know how to check running processes Linux , sort them and find out insightful details about them.
Table of Contents
The Definition of a Process
A process is the execution of a program. To launch it, you should perform one of the two actions:
- Issue a command with the help of the terminal
- Open an app
The mission of a command consists in generating a process. An app is capable of running several processes for various tasks. Just an example: as soon as you open a new tab in Google Chrome, this browser can launch a new process.
Each Linux process receives an individual PID (process identification number). The system might use old identification numbers repeatedly if there are no any other combinations to choose from.
All the processes can be classified into two categories: background or foreground. Any command that runs in the shell automatically belongs to the latter type. You’ll be able to switch to other commands only when the current process is completed and leaves the shell it used to occupy empty.
Sometimes, the system might take too much time to complete the command. In such a situation, it makes sense to relocate it to the background by inserting an ampersand (&) at the end of the command. Thanks to this trick, the shell should enable you to assign new tasks to it.
At times, you might need to terminate a process because it consumes too many resources. If you, vice versa, would like to system to provide extra resources to the current process, you can modify its priority. To achieve these goals, it would be reasonable to ask the system to exhibit the current processes.
Listing Current Processes
To list processes, you can resort to the following commands:
- ps (exhibits all processes)
- top (reveals a real-time list of active ones)
- htop (demonstrates real-time results)
Below, we’ll analyze in detail all of them.
The Specifics of the “ps” Command
This acronym stands for “process statuses”. It creates a snapshot of all current processes. You can use it with or without additional options or arguments. In the latter case, it should show a list of active processes along with four columns:
- TTY (terminal name)
- TIME (running time)
- CMD (the name of the command that begins the process)
To obtain in-depth data about your current processes, you can resort to ps aux. Here is what each element in “aux” stands for:
- a demonstrates all current processes of all users
- u exhibits extra details of the processes
- x reveals all processes executed from elsewhere but not the terminal
The ps -axjf command arranges processes hierarchically. Parent processes go first and their children go second.
You can benefit from the following variations of the ps command:
- Ps -C process_name — filters the list by the process name and demonstrates all children of the indicated parent
- ps -T prints — shows current processes executed from the terminal
- ps -e or ps -A — exhibits current processes in the UNIX format
- ps -u [username] — displays all current processes of a specific user
The ps command in all its versions delivers static results, so it would be unreasonable to compare it to the Windows task manager.
The Essence of the “top” Command
This one enables you to detect the processes that require a large amount of resources. It sorts the list by CPU usage, starting with the processes that consume the most resources. Plus, you can rely on it to find out whether a particular process is active or not.
The results will not be static. The system will be updating them in real-time.
The Usage of the “htop” Command
It is largely similar to the previous one but exhibits the data in a more convenient format. Here are a few examples of the activities that it makes available to you:
- Scroll horizontally or vertically
- Check all the processes with their command lines
- Choose item with the help of the mouse
- Terminate processes without typing in their identification numbers
- Increase or decrease the prioroty of several processes at a time
The biggest challenge related to htop is that you might have to install it manually. It might be unavailable by default.
atop and prgrep: Additional Commands That You Might Want to Remember
The three above-mentioned commands can be considered as the minimum required basics. But you might also learn to use the atop one. It enables you to check the current load on the system. It reveals how busy the hardware resources are right now. Plus, it allows you to identify the processes that create the largest part of this load. You won’t need to think too long about which processes to stop to enhance the productivity of the system.
The pgrep command helps you to find a particular process. You should type in the name of this process and maybe also its identification number. If you insert the PID, the system should reveal more details about the process. If you rely on the name only, you’ll simply locate the process and will be able to stop or modify it.
Hopefully, you found this article informative and now you know how to list all the current processes in Linux. You should master the usage of the three commands: ps, top and htop. The last two ones are largely similar to each other. The ps one is available in various modifications. The atop and pgrep programs can also come in handy. Once you’ve detected all the current processes, it should be easy for you to decide which ones you’d love to terminate, which ones to relocate to the background and whose priority should be modified.