On your Linux system, each application you use and each command you issue starts a task or process. To maintain the best system performance How to List Running Processes in Linux? you will need to control processes as a system administrator.
This lesson will go through various Linux commands you may use to manage and list active processes.
- A Linux-running computer
- A username with root or sudo rights
- Access to the command line and terminal window
Overview of List Running Processes in Linux
The carrying out of a program is a procedure. They can be started when an application is opened or when a command is entered into the command-line terminal. For certain tasks, a program can, however, execute numerous processes. For instance, each time a new tab is opened in Google Chrome, a fresh process will launch.
How to List Running Processes in Linux? A procedure can start in the foreground or the background. Linux processes are each given a distinct PID (process identification number).
Processes may occasionally use a lot of resources and need to be terminated. Alternatively, there may be occasions when you want to raise a process priority level to force the system to give it additional resources. In any event, to complete any of these activities, you must list the Linux processes that are now active.
How to List Running Processes in Linux?
Use one of the three commands: ps, top, or htop to list processes in Linux. While the top and htop sort by CPU utilization, the ps tool delivers a static snapshot of all processes.
How to List Running Processes in Linux? Let’s explore each of them in more detail.
Making use of the “ps” Command
All active processes are captured in a snapshot using the ps (process statuses) tool. Consequently, the outcomes are fixed, unlike the Windows task manager.
The PID, terminal name (TTY), running time (TIME), and the name of the command that launched the process are the four key columns that are returned when this command is used without any additional arguments or options (CMD). To learn more specific details about your active processes, utilize ps aux. The details of each defense are as follows:
An option displays a list of all users active processes.
U option offers extra details including the proportion of memory and CPU utilization, the process state code, and the owner of the processes.
All processes not started from the terminal are listed using the x option. Daemons, which are system-related processes that run in the background as the system boots up, are a prime illustration of this.
Use the ps -axjf command to list Linux processes in a hierarchical manner. The shell will arrange procedures so that children come before parents in this fashion.
Here are some additional typical instances of the ps command that lists active processes in Linux aside from those two choices:
Ps -u [username] displays a list of all active processes for that user.
Active Linux processes are displayed using the UNIX-style ps -e or ps -A commands.
ps -T displays information about running processes from the terminal.
The list will be filtered by the process name using Ps -C process name. This command also displays all offspring of the specified process.
Making use of the “top” Command
The top command is used to identify processes that are resource-hungry. The process that uses the most resources will be at the top of the list after this Linux program sorts it by CPU utilization. Checking to see if a certain process is active is also helpful.
The output of the top command is updated on a regular basis, unlike the ps command. This implies that the CPU utilization and operating time will be updated in real-time. The following keys can be used to interact with the list after the shell returns it:
Keys | Functions |
k | Kills a process |
M | Sorts the list by memory usage. |
N | Sorts the list by PID. |
r | Changes the priority of a process. |
h | Displays the help window. |
z | Displays running processes in colors. |
d | Changes the refresh time interval. |
c | Displays the absolute path of a process. |
CTRL+C;or;q | Stops the top command. |
How to List Running Processes in Linux? Be careful not to enable the caps lock because the keys above are case-sensitive.
Running “htop” Command
When showing your Linux processes, both the htop and top commands provide identical information, but the former has more user-friendly features that are useful for regular process management.
First things first, you can scroll both vertically and horizontally with the htop command. As a result, you may view a complete list of all of your Linux processes as well as their whole command lines.
Additionally, the command enables you to pick items with the mouse, kill processes without entering their PIDs, quickly adjust the priority of numerous processes, and more.
Unfortunately, you must manually install this command because the majority of Linux distributions don’t include it.
Run the following command to install htop if you use Ubuntu:
Installing htop using sudo apt-get
Once it is installed, you may type htop to view a list of all the Linux processes. The htop command also offers a number of keyboard shortcuts, similar to the prior command:
Keys | Functions |
F9 | To kill a process. |
F8 | Increase the priority of a process. |
F7 | Decrease the priority of a process. |
F6 | Sort processes by any column. |
F5 | Display processes in a tree view. |
F4 | Filter the processes by name. |
F3 | Search for a process. |
F2 | Open the htop setup. |
F1 | Display the help menu. |
Using the command “atop”
A tool for keeping an eye on system resources in Linux is the topping command. It is a full-screen ASCII performance tool that records and summarizes information about all server processes.
Atop will display the resource utilization for the CPU, RAM, swap, discs, and network in 10-second intervals after it has been run. Atop will continue to run in the background to do ongoing server analysis (up to 28 days by default).
Several benefits are as follows:
- Gathers resource-use data for all users and processes with the same name.
- Highlights in color the most important resources (red).
- Displays resource utilization across all processes, even those that have finished or been closed.
- Threads inside processes are observed (except for unused ones).
- To keep track of TCP, UDP, and network bandwidth, use netatop kernel mobile.
Either of the following commands will allow you to install the above command:
Ubuntu/Debian
sudo apt install atop
CentOS/RHEL/Fedora
sudo dnf install atop
Run the above command after installation to see all the processes that are using the system’s resources.
The list of possible arguments is shown below, along with brief summaries of each:
Command | Description |
man atop | Displays the top command manual page. |
atop -l | Displays the average-per-second total values. |
atop -a | Displays the active processes during the last intervals. |
atop -c | Displays the command line per process. |
atop -m | Displays the memory-related information. |
atop -d | Displays the disk-related information. |
atop -n | Displays the network information. |
atop -s | Displays the scheduling details. |
atop -v | Displays the various info (for example PPID, user, or time). |
atop -y | Displays the individual threads. |
To sort processes once the above is running, press one of the shortcut keys mentioned below:
Keys | Functions |
a | Sorts in order of the most active resources. |
c | Reverts to sorting by the CPU consumption (default). |
d | Sorts in order of disk activity. |
m | Sorts in order of memory usage. |
n | Sorts in order of network activity. |
Conclusion
Understanding how to list every process that is active on your Linux operating system is essential. When managing processes How to List Running Processes in Linux? the information will be helpful. What command do you like most out of the three? Post your comments in the space provided below!