How to Check Running Process in Linux

This post will guide you how to check running process from the command line in Linux operating systems. How to list, kill and manage process in Linux.

List Running Processes


If you want to List all running processes at the shell prompt in your Linux, you can use ps command with -aux option or -a option, type:

$ ps -aux

Or

$ ps -a

Outputs:

devops@devops:~$ ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.6 0.7 225508 7104 ? Ss 01:49 0:01 /sbin/init splash
root 2 0.0 0.0 0 0 ? S 01:49 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? I< 01:49 0:00 [rcu_gp]
root 4 0.0 0.0 0 0 ? I< 01:49 0:00 [rcu_par_gp]
root 5 0.0 0.0 0 0 ? I 01:49 0:00 [kworker/0:0-ata]
root 6 0.0 0.0 0 0 ? I< 01:49 0:00 [kworker/0:0H-kb]
root 7 0.1 0.0 0 0 ? I 01:49 0:00 [kworker/u2:0-ev]
root 8 0.0 0.0 0 0 ? I< 01:49 0:00 [mm_percpu_wq]
root 9 0.0 0.0 0 0 ? S 01:49 0:00 [ksoftirqd/0]
root 10 0.0 0.0 0 0 ? I 01:49 0:00 [rcu_sched]
root 11 0.0 0.0 0 0 ? S 01:49 0:00 [migration/0]
root 12 0.0 0.0 0 0 ? S 01:49 0:00 [idle_inject/0]
root 13 0.1 0.0 0 0 ? I 01:49 0:00 [kworker/0:1-eve]
root 14 0.0 0.0 0 0 ? S 01:49 0:00 [cpuhp/0]
root 15 0.0 0.0 0 0 ? S 01:49 0:00 [kdevtmpfs]
root 16 0.0 0.0 0 0 ? I< 01:49 0:00 [netns]
root 17 0.0 0.0 0 0 ? S 01:49 0:00 [rcu_tasks_kthre]
root 18 0.0 0.0 0 0 ? S 01:49 0:00 [kauditd]
root 19 0.0 0.0 0 0 ? S 01:49 0:00 [khungtaskd]
root 20 0.0 0.0 0 0 ? S 01:49 0:00 [oom_reaper]
root 21 0.0 0.0 0 0 ? I< 01:49 0:00 [writeback]

If you want to search for a specific process, and you can use ps command in combination with grep command.
For example, you want to search for a process called systemd, just issuing the following command:

$ ps -aux | grep systemd

Outputs:

devops@devops:~$ ps aux | grep systemd
root 281 0.0 1.3 119612 13700 ? S root 293 0.1 0.2 46276 2884 ? Ss 01:49 0:00 /lib/systemd/systemd-udevd
systemd+ 699 0.0 0.3 146108 3820 ? Ssl 01:49 0:00 /lib/systemd/systemd-timesyncd
message+ 819 0.1 0.4 51356 4284 ? Ss 01:49 0:00 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
root 849 0.0 0.4 70732 4060 ? Ss 01:49 0:00 /lib/systemd/systemd-logind
systemd+ 968 0.0 0.3 70756 3968 ? Ss 01:49 0:00 /lib/systemd/systemd-resolved
gdm 1382 0.0 0.4 77028 4928 ? Ss 01:50 0:00 /lib/systemd/systemd --user
gdm 1397 0.0 0.3 50328 3452 ? Ss 01:50 0:00 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
devops 3931 0.0 0.7 76908 7336 ? Ss 01:50 0:00 /lib/systemd/systemd --user
devops 4708 0.0 0.1 21532 1036 pts/3 S+ 01:55 0:00 grep --color=auto systemd

Lookup Process


If you only want to lookup a process by process name, and you can use another command called pgrep. For example, you wish to find a process by a process name called “systemd”, just using the following commad:

$ pgrep systemd

Outputs:

devops@devops:~$ pgrep systemd
1
281
293
699
849
968
1382
3931

View Top Process List


If you want to get a list of top process that using the most memory or CPU in your current Linux system, and you can use top command to get a dynamic real-tme view of a running system. type the following command:

$ top

Outputs:

top - 02:00:19 up 10 min, 1 user, load average: 0.00, 0.26, 0.31
Tasks: 208 total, 1 running, 174 sleeping, 0 stopped, 0 zombie
%Cpu(s): 7.5 us, 3.0 sy, 1.9 ni, 86.8 id, 0.7 wa, 0.0 hi, 0.1 si, 0.0 st
KiB Mem : 1006668 total, 72412 free, 518380 used, 415876 buff/cache
KiB Swap: 2097148 total, 1925116 free, 172032 used. 304852 avail Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
4737 devops 20 0 51336 3952 3236 R 11.8 0.4 0:00.03 top
1 root 20 0 225564 7060 4996 S 0.0 0.7 0:01.43 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd
3 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 rcu_gp
4 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 rcu_par_gp
6 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 kworker/0:0H-kb
7 root 20 0 0 0 0 I 0.0 0.0 0:00.31 kworker/u2:0-ev
8 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 mm_percpu_wq
9 root 20 0 0 0 0 S 0.0 0.0 0:00.23 ksoftirqd/0
10 root 20 0 0 0 0 I 0.0 0.0 0:00.20 rcu_sched
11 root rt 0 0 0 0 S 0.0 0.0 0:00.00 migration/0
12 root -51 0 0 0 0 S 0.0 0.0 0:00.00 idle_inject/0
13 root 20 0 0 0 0 I 0.0 0.0 0:00.54 kworker/0:1-eve
14 root 20 0 0 0 0 S 0.0 0.0 0:00.00 cpuhp/0
15 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kdevtmpfs
16 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 netns
17 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_tasks_kthre
18 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kauditd
19 root 20 0 0 0 0 S 0.0 0.0 0:00.00 khungtaskd
20 root 20 0 0 0 0 S 0.0 0.0 0:00.00 oom_reaper
21 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 writeback
22 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kcompactd0
23 root 25 5 0 0 0 S 0.0 0.0 0:00.00 ksmd
24 root 39 19 0 0 0 S 0.0 0.0 0:00.00 khugepaged

Kill Process


If you want to kill a process by Process ID in Linux, and you can the kill command with process Id. And you need to use ps or pgrep command to lookup the process ID.
For example, you want to kill process ID of a process named “mysqld”, just running the following command:

$ ps aux | grep mysqld
$ kill pid

Outputs:

devops@devops:~$ ps aux | grep mysqld
mysql 1372 0.1 7.5 1157788 75900 ? Sl 01:50 0:01 /usr/sbin/mysqld --daemonize --pid-file=/run/mys

devops@devops:~$ sudo kill 1372
[sudo] password for devops:
devops@devops:~$ ps aux | grep mysqld
devops 4830 0.0 0.1 21532 1044 pts/3 S+ 02:05 0:00 grep --color=auto mysqld
devops@devops:~$

Kill Process by Name


If you want to kill a process by name directly, and you can use pkill command.

$ sudo pkill process_name
$ sudo pkill mysql

Outputs:

devops@devops:~$ ps aux | grep mysql
mysql 4911 0.7 17.8 1157388 179464 ? Sl 02:07 0:00 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid
devops 4972 0.0 0.1 21532 1116 pts/3 S+ 02:08 0:00 grep --color=auto mysql

devops@devops:~$ sudo pkill mysql

devops@devops:~$ ps aux | grep mysql
devops 4987 0.0 0.1 21532 1084 pts/3 S+ 02:08 0:00 grep --color=auto mysql

Kill Processes by Name


If you want to kill all processes running any of the specified commands.

For example, you want to kill all processes associated with “apache2” process, and you can use killall command to kill processes by name. type:

$ sudo killall apache2

Conclusion


You should know that how to list/find/kill running process in your CentOS or RHEL or Ubuntu Linux system with ps/pgrep/kill/killall commands.

You might also like:

Sidebar



back to top