You may sometimes want to see what applications are running and terminate some of them based on their process IDs in terminal. To do this ps aux is used for listing and kill -9 for termination the process.


Listing option 1


Command ps aux lets you dump all processes on screen in one go.


inanzzz@inanzzz:~$ ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.1 34052 3144 ? Ss 10:42 0:02 /sbin/init
root 2 0.0 0.0 0 0 ? S 10:42 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? S 10:42 0:02 [ksoftirqd/0]
root 5 0.0 0.0 0 0 ? S< 10:42 0:00 [kworker/0:0H]
.....

Listing option 2


Command ps aux | less lets you list processes one by one.


inanzzz@inanzzz:~$ ps aux | less
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.1 34052 3144 ? Ss 10:42 0:02 /sbin/init
root 2 0.0 0.0 0 0 ? S 10:42 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? S 10:42 0:02 [ksoftirqd/0]
root 5 0.0 0.0 0 0 ? S< 10:42 0:00 [kworker/0:0H]
.....
#cursor flashes here for you to hit enter to show next process

Listing option 3


Command ps aux | grep terminal lists only applications which are related to "terminal" keyword.


inanzzz@inanzzz:~$ ps aux | grep terminal
inanzzz 6306 0.6 0.9 648484 18800 ? Sl 18:02 0:04 gnome-terminal
inanzzz 6400 0.0 0.0 15944 916 pts/3 S+ 18:14 0:00 grep --color=auto terminal

Listing option 4


Command top lists all running applications in OS.


inanzzz@inanzzz:~$ top

Processes: 277 total, 2 running, 14 stuck, 261 sleeping, 1154 threads 10:05:29
Load Avg: 1.41, 1.42, 1.42 CPU usage: 8.80% user, 6.42% sys, 84.76% idle
SharedLibs: 12M resident, 12M data, 0B linkedit. MemRegions: 92798 total, 3171M resident, 68M private, 1458M shared.
PhysMem: 5926M used (1675M wired), 10G unused.
VM: 707G vsize, 1063M framework vsize, 32763508(0) swapins, 34121836(0) swapouts.
Networks: packets: 26225324/30G in, 16810622/2649M out. Disks: 4214577/203G read, 5759781/303G written.

PID COMMAND %CPU TIME #TH #WQ #PORT MEM PURG CMPRS PGRP PPID STATE BOOSTS %CPU_ME
46022 top 3.0 00:05.91 1 0 17 3044K 0B 0B 46022 46018 sleeping *0[1] 0.00000
46018 bash 0.0 00:00.02 1 0 15 652K 0B 0B 46018 46017 sleeping *0[1] 0.00000
46017 login 0.0 00:00.15 2 0 27 1068K 0B 0B 46017 20904 sleeping *0[9] 0.00000
46015 Google Chrom 0.0 00:00.81 11 1 88 30M 0B 0B 20899 20899 stuck *0[26] 0.00000

Terminate process


Command kill -9 terminates process with given ID.


inanzzz@inanzzz:~$ ps aux | grep terminal
inanzzz 6306 0.6 0.9 648484 18800 ? Sl 18:02 0:04 gnome-terminal
inanzzz 6400 0.0 0.0 15944 916 pts/3 S+ 18:14 0:00 grep --color=auto terminal
inanzzz@inanzzz:~$ sudo kill -9 6400
[sudo] password for inanzzz: