One can use the Ubuntu Linux 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 the process on Ubuntu Linux.

 

Check running process in Ubuntu Linux

 

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

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

 

Let us see some example and usage for Ubuntu Linux in details.

 

How to manage processes from the Ubuntu Linux terminal

 

The ps command is a traditional Ubuntu Linux command to lists running processes. The following command shows all processes running on your system:

{admin@ubuntu-box:~}$ ps -aux
{admin@ubuntu-box:~}$ sudo ps -a
{admin@ubuntu-box:~}$ sudo ps -U admin
{admin@ubuntu-box:~}$ ps -U tom

 

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

admin    30992  0.0  0.3  40092  3492 pts/0    R+   06:31   0:00 ps -U admin -au

 

Where,

admin – User name

30992 – PID (Ubuntu Linux process ID)

06:31 – Process start time

ps -U admin -au – Actual processor command with command line arguments

 

There may be too many processes. Hence, it uses the following less command/more command as a pipe to display process one screen at a time:

{admin@ubuntu-box:~}$ ps -aux | more
{admin@ubuntu-box:~}$ sudo ps -aux | less

 

Press q to exit from above Ubuntu Linux pagers. You can search for a particular Ubuntu Linux process using grep command/egrep command:

{admin@ubuntu-box:~}$ ps aux | grep nginx
{admin@ubuntu-box:~}$ sudo ps aux | grep vim
{admin@ubuntu-box:~}$ sudo ps aux | grep chromium-browser
{admin@ubuntu-box:~}$ sudo ps -aux | egrep 'sshd|openvpn'

 

Ubuntu Linux pgrep command

 

Many variants of Ubuntu Linux comes with the pgrep command to search/find process. The syntax is:

{admin@ubuntu-box:~}$ pgrep process
{admin@ubuntu-box:~}$ sudo pgrep sshd
{admin@ubuntu-box:~}$ pgrep vim
{admin@ubuntu-box:~}$ pgrep chromium-browser
{admin@ubuntu-box:~}$ pgrep -l nginx

 

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

 

Ubuntu Linux top and htop commands

 

The top command is another highly recommended method to see your Ubuntu Linux servers resource usage. One can see a list of top process that using the most memory or CPU or disk.

{admin@ubuntu-box:~}$ top
{admin@ubuntu-box:~}$ sudo top
{admin@ubuntu-box:~}$ sudo top [options]

 

The htop is easy to use process viewer from the CLI on Ubuntu Linux. Try it as follows:

{admin@ubuntu-box:~}$ htop
{admin@ubuntu-box:~}$ sudo htop
{admin@ubuntu-box:~}$ sudo htop [options]

 

Press q to exit from above top/htop Ubuntu Linux commands.

 

Ubuntu Linux kill command

 

Want to kill a process? Try kill command. The syntax is:

{admin@ubuntu-box:~}$ kill pid
{admin@ubuntu-box:~}$ kill -signal pid

 

Find PID using ps, pgrep or top command. Say you want to kill a PID # 3932, run:

{admin@ubuntu-box:~}$ kill 3932

 

For some reason if the process can not be killed, try forceful killing:

{admin@ubuntu-box:~}$ kill -9 3932

 

OR

{admin@ubuntu-box:~}$ kill -KILL 3932

 

Ubuntu Linux pkill command

If you wish to kill a process by name, try pkill command. The syntax is:

{admin@ubuntu-box:~}$ pkill processName
{admin@ubuntu-box:~}$ pkill vim
{admin@ubuntu-box:~}$ pkill firefox
{admin@ubuntu-box:~}$ pkill -9 emacs
{admin@ubuntu-box:~}$ sudo pkill -KILL php7-fpm

 

Ubuntu Linux killall command

The killall command kills processes by name, as opposed to the selection by PID as done by kill command:

{admin@ubuntu-box:~}$ killall vim
{admin@ubuntu-box:~}$ killall -9 emacs

 

Ubuntu Linux 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 Linux 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 server. You can set a very low priority, enter:

{admin@ubuntu-box:~}$ nice -n 13 cc -c *.c &

 

Set a very high priority for a kernel update. Before rebooting Ubuntu Linux server, run:

nice --10 wall <<end
System reboots in 5 minutes for Ubuntu Linux kernel update!
Save all your work!!!
-- Sysadmin
end

 

To change the priority of a running process, type the following:

{admin@ubuntu-box:~}$ renice {Priority} -p {PID}
{admin@ubuntu-box:~}$ renice {Priority} {PID}
{admin@ubuntu-box:~}$ pgrep vim
renice 10 69947
{admin@ubuntu-box:~}$ sudo renice -10 $(pgrep vim)

 

Conclusion

This page shows how to manage the process on the Ubuntu Linux terminal. 

 

Was this answer helpful? 0 Users Found This Useful (0 Votes)