How to check running process in Ubuntu using command line

I am a new sysadmin for the Ubuntu operating system. How do I check running process in Ubuntu using the command line option?

One can use the Ubuntu command line or terminal app to display a running process, change their priorities level, delete process and more. This page shows how to use various commands to list, kill and manage process on Ubuntu.

Adblock detected 😱
My website is made possible by displaying online advertisements to my visitors. I get it! Ads are annoying but they help keep this website running. It is hard to keep the site running and producing new content when so many people block ads. Please consider donating money to the nixCraft via PayPal/Bitcoin, or become a supporter using Patreon.

Check running process in Ubuntu

The procedure to monitor the running process in Ubuntu using the command line is as follows:

  1. Open the terminal window on Ubuntu
  2. For remote Ubuntu server use the ssh command for log in purpose
  3. Type the ps aux command to see all running process in Ubuntu
  4. Alternatively, you can issue the top command to view running process in Ubuntu

Please note that [vivek@ubuntuLTS:~]$ is my shell prompt. You need to type all commands after that prompt.

How to manage processes from the Ubuntu terminal

The ps command is a traditional Ubuntu Linux command to lists running processes. The following command shows all processes running on your Ubuntu based system:
[vivek@ubuntuLTS:~]$ ps -aux
[vivek@ubuntuLTS:~]$ sudo ps -a

The process ID (PID) is essential to kill or control process on Ubuntu. For example consider the following outputs:

esha 42421  0.0  0.0 13160 8452  -  S    22:18   0:00.03 firefox


  1. esha – User name
  2. 42421 – PID (Ubuntu Linux process ID)
  3. 22:18 – Process start time
  4. firefox – Actual process or command

There may be too many processes. Hence, it uses the following less command/more command as pipe to display process one screen at a time:
[vivek@ubuntuLTS:~]$ ps -aux | more
[vivek@ubuntuLTS:~]$ sudo ps -aux | less

Press q to exit from above Ubuntu Linux pagers. You can search for a particular Ubuntu process using grep command/egrep command:
[vivek@ubuntuLTS:~]$ ps aux | grep nginx
[vivek@ubuntuLTS:~]$ sudo ps aux | grep vim
[vivek@ubuntuLTS:~]$ sudo ps -aux | egrep 'sshd|openvpn'

pgrep command

Ubuntu comes with the pgrep command to search/find process. The syntax is:
[vivek@ubuntuLTS:~]$ pgrep process
[vivek@ubuntuLTS:~]$ sudo pgrep sshd
[vivek@ubuntuLTS:~]$ pgrep vim
[vivek@ubuntuLTS:~]$ pgrep -l

The -l option passed to the pgrep command to display long format and process name too.

top command

The top command is another highly recommended method to see your Ubuntu servers resource usage. One can see a list of top process that using the most memory or CPU or disk. Run:
[vivek@ubuntuLTS:~]$ top
[vivek@ubuntuLTS:~]$ sudo top
[vivek@ubuntuLTS:~]$ sudo top [options]

Ubuntu kill command

Want to kill a process on Ubuntu? Try kill command. The syntax is:
[vivek@ubuntuLTS:~]$ kill pid
[vivek@ubuntuLTS:~]$ kill -signal pid

Find PID using ps, pgrep or top command. Say you want to kill a PID # 25123, run:
[vivek@ubuntuLTS:~]$ kill 25123
For some reason if the process can not be killed, try forceful killing:
[vivek@ubuntuLTS:~]$ kill -9 25123
[vivek@ubuntuLTS:~]$ kill -KILL 25123

pkill command

If you wish to kill a process by name, try pkill command on Ubuntu. The syntax is:
[vivek@ubuntuLTS:~]$ pkill processName
[vivek@ubuntuLTS:~]$ pkill vim
[vivek@ubuntuLTS:~]$ pkill firefox
[vivek@ubuntuLTS:~]$ pkill -9 emacs
[vivek@ubuntuLTS:~]$ sudo pkill -KILL php7-fpm

killall command

The killall command kills processes by name, as opposed to the selection by PID as done by kill command:
[vivek@ubuntuLTS:~]$ killall vim
[vivek@ubuntuLTS:~]$ killall -9 emacs

nice and renice command

The primary purpose of the nice command is to run a process/command at a lower or higher priority. Use the renice command to alter the nice value of one or more running Ubuntu processes. The nice value can range from -20 to 19, with 19 being the lowest priority. Say, you want to compile software on a busy Ubuntu Linux 18.04 LTS server. You can set a very low priority, enter:
[vivek@ubuntuLTS:~]$ nice -n 13 cc -c *.c &
Set a very high priority for a kernel update. Before rebooting Ubuntu server, run:

[vivek@ubuntuLTS:~]$  nice --10 wall <<end
System reboots in 5 minutes for Ubuntu Linux kernel update! 
Save all your work!!!
-- Sysadmin

[vivek@ubuntuLTS:~]$ nice –10 wall <<end
System reboots in 5 minutes for Ubuntu Linux kernel update!
Save all your work!!! — Sysadmin

To change the priority of a running process, type the following:
[vivek@ubuntuLTS:~]$ renice {Priority} -p {PID}
[vivek@ubuntuLTS:~]$ renice {Priority} {PID}
[vivek@ubuntuLTS:~]$ pgrep vim
[vivek@ubuntuLTS:~]$ renice 10 69947
[vivek@ubuntuLTS:~]$ sudo renice -10 $(pgrep vim)


This page shows how to manage the process on the Ubuntu terminal. For further info see man pages or our example pages:

Exit mobile version