OSETC TECH

How To Check Running Process in Ubuntu

This post will guide you how to check All running proceses from the command line in your Ubuntu 16.04 or 18.04 system. How do I check running process using ps command under Ubuntu or Debian based system.

List All Running Processes using ps command in Ubuntu


If you want to list all running processes in your Ubuntu system, and you can open a terminal, and type “ps -aux” command at the shell prompt:

$ ps aux | less
$ ps aux | more
$ ps -a

Outputs:

$ ps aux | less
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.1 0.6 225768 6400 ? Ss 01:48 0:01 /sbin/init splash
root 2 0.0 0.0 0 0 ? S 01:48 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? I< 01:48 0:00 [rcu_gp]
root 4 0.0 0.0 0 0 ? I< 01:48 0:00 [rcu_par_gp]
root 6 0.0 0.0 0 0 ? I< 01:48 0:00 [kworker/0:0H-kb]
root 8 0.0 0.0 0 0 ? I< 01:48 0:00 [mm_percpu_wq]
root 9 0.0 0.0 0 0 ? S 01:48 0:00 [ksoftirqd/0]
root 10 0.0 0.0 0 0 ? I 01:48 0:00 [rcu_sched]
root 11 0.0 0.0 0 0 ? S 01:48 0:00 [migration/0]
root 12 0.0 0.0 0 0 ? S 01:48 0:00 [idle_inject/0]
root 13 0.0 0.0 0 0 ? I 01:48 0:00 [kworker/0:1-eve]
root 14 0.0 0.0 0 0 ? S 01:48 0:00 [cpuhp/0]
root 15 0.0 0.0 0 0 ? S 01:48 0:00 [kdevtmpfs]
root 16 0.0 0.0 0 0 ? I< 01:48 0:00 [netns]
root 17 0.0 0.0 0 0 ? S 01:48 0:00 [rcu_tasks_kthre]
root 18 0.0 0.0 0 0 ? S 01:48 0:00 [kauditd]
root 19 0.0 0.0 0 0 ? S 01:48 0:00 [khungtaskd]
root 20 0.0 0.0 0 0 ? S 01:48 0:00 [oom_reaper]
root 21 0.0 0.0 0 0 ? I< 01:48 0:00 [writeback]
root 22 0.0 0.0 0 0 ? S 01:48 0:00 [kcompactd0]
root 23 0.0 0.0 0 0 ? SN 01:48 0:00 [ksmd]
root 24 0.0 0.0 0 0 ? SN 01:48 0:00 [khugepaged]
root 25 0.0 0.0 0 0 ? I< 01:48 0:00 [crypto]
root 26 0.0 0.0 0 0 ? I< 01:48 0:00 [kintegrityd]
root 27 0.0 0.0 0 0 ? I< 01:48 0:00 [kblockd]
root 28 0.0 0.0 0 0 ? I< 01:48 0:00 [tpm_dev_wq]
root 29 0.0 0.0 0 0 ? I< 01:48 0:00 [ata_sff]
root 30 0.0 0.0 0 0 ? I< 01:48 0:00 [md]

Check Running Process using top command in Ubuntu


You can also use top command to display Linux processes, and it will provide a dynamic real-time view of a running system. and it can display system summary information as well as a list of processes or threads currently being managed by the linux kernel. type:

$ top

outputs:

top - 02:09:20 up 20 min, 2 users, load average: 0.00, 0.14, 0.25
Tasks: 279 total, 1 running, 242 sleeping, 0 stopped, 0 zombie
%Cpu(s): 6.3 us, 2.6 sy, 0.9 ni, 88.8 id, 0.9 wa, 0.0 hi, 0.4 si, 0.0 st
KiB Mem : 1006580 total, 74704 free, 690044 used, 241832 buff/cache
KiB Swap: 2097148 total, 1335628 free, 761520 used. 133292 avail Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
5831 devops 20 0 44216 4052 3344 R 23.5 0.4 0:00.05 top
1 root 20 0 225768 6380 4712 S 0.0 0.6 0:01.71 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd

Find the ID of Process using pgrep command in Ubuntu


If you want to find a process by name in your Ubuntu system, and you can use the pgrep command at the shell prompt, type:

$ pgrep processName
$ pgrep apache2

Outputs:

devops@devops-ubuntu:~$ pgrep apache2
1365
4276
4277
4278
4279
4280

Kill a Process using kill command in Ubuntu


If you want to kill a process on your Ubuntu system, and you can use kill command from the command line, type:

$ sudo kill pidNumber
$ sudo kill -i pidNumber

You need to find the ID of Process using pgrep or pidof command. For example, you want to kill a process named apache2, its pid is 4280, type:

$ sudo kill -9 4280

you can also kill a process by name using pkill or killall command, type:

$ sudo killall apache2

or

$ sudo pkill apache2

Conclusion


You should know that how to check running process using ps/top/pgrep commands in your Ubuntu Linux system.