Use the ps Command to View | List Processes on Ubuntu 18.04 | 16.04 with Examples

This brief tutorial shows students and new users how to use the ps command on Ubuntu to list and locate currently-running processes…

For example, if you have an application that is locked-up or unresponsive and but gobbling up all your CPU time and/or RAM, you use the ps command to look up the application process and use the kill command to kill it and restore the system to its normal operation…

For students or new users looking for a Linux system to start learning on, the easiest place to start is Ubuntu Linux OS…. It’s a great Linux operating system for beginners..

Ubuntu is an open source Linux operating systems that runs on desktops, laptops, server and other devices…

When learning Ubuntu, you will find that Linux isn’t so different than Windows and other operating systems in so many ways, especially when it comes to using Ubuntu to get work done.…

Both Ubuntu and Windows systems allow you to be productive, easy to use, reliable and enable you to install and run thousands of programs from gaming to productivity suite software for individuals and businesses..

However, when you’re learning to use and understand Ubuntu Linux, you should also learn how to use the command line to terminal.. Most Linux users should be able to do some basic command line tasks..

This tutorial is going to show you how…..

When you’re ready to learn how to use the ps commands, follow the guide below:

 

About ps command:

The ps command is a command line utility that helps you view details of currently-running processes with options to kill or terminate processes that are not behaving normally..

 

Syntax:

The syntax is the rule and format of how the ps command can be used… These syntax options can be reordered, but a straight format must be followed.,.

Below is an example syntax of how to use the ps command….

ps [options]

 

Options:

The command line options are switches or flags that determined how the commands are executed or controlled… they modify the behavior of the commands… they are separated by spaces and followed after the commands…

Below are some options of the ps command:

 

    options Replace command a command you want to look up
  ps  –help list ps –help list command option common options you can use with the ps command
  ps –help all ps –help all command option gives you all the possible command options you can use with ps
  ps –help misc ps –help misc gives you miscellaneous options you can use with the ps command
 ps –help simple ps –help  simple provides you basic options you can use with the ps command
–help Display a help message

 

Examples:

Below are some examples of how to run and use the ps on Ubuntu Linux…

Simply run the ps to invoke it.

Running ps command without options will display a list a processes started by the account running the command..

Output:
  PID TTY          TIME CMD
 2658 pts/0    00:00:00 bash
19229 pts/0    00:00:00 ps

These represent the columns..

  • PID: The process ID number of the running process.
  • TTY: The console name the user is logged in at.
  • TIME: The CPU processing time used by the process.
  • CMD: The command name that started the process

 

For example, if you want to list all processes currently running on the system, even those started by other users, simple run the ps command with the -e or -A option..

Example:

ps -e 

This will list all the processes running, but the list is going to be long.. So pipe the command with less to break the list by screen…

Example:

ps -e | less

You should see something similar to the list below:

Output:
  PID TTY          TIME CMD
    1 ?        00:00:03 systemd
    2 ?        00:00:00 kthreadd
    3 ?        00:00:00 rcu_gp
    4 ?        00:00:00 rcu_par_gp
    6 ?        00:00:00 kworker/0:0H-kb
    7 ?        00:00:00 kworker/u4:0-ev
    8 ?        00:00:00 mm_percpu_wq
    9 ?        00:00:00 ksoftirqd/0
   10 ?        00:00:00 rcu_sched
   11 ?        00:00:00 migration/0
   12 ?        00:00:00 idle_inject/0
   14 ?        00:00:00 cpuhp/0
   15 ?        00:00:00 cpuhp/1

When you want to know more details of running processes, including displaying their parent processes, simple run the ps command with the options:

Example:

ps -eH | less

This will display processes along with their parents

Output:
 2095 ?        00:00:00     gdm-session-wor
 2119 tty2     00:00:00       gdm-x-session
 2121 tty2     00:00:20         Xorg
 2130 tty2     00:00:00         gnome-session-b
 2267 ?        00:00:00           ssh-agent
 2300 tty2     00:00:46           gnome-shell
 2334 tty2     00:00:00             ibus-daemon
 2338 tty2     00:00:00               ibus-dconf
 2599 tty2     00:00:00               ibus-engine-sim
 2416 tty2     00:00:00           gsd-power

This list all processes using the full-format use the ps command with the -ef option

Example:

ps -ef | less

You should see similar list as shown below:

Output:
UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0 12:07 ?        00:00:03 /sbin/init splash
root         2     0  0 12:07 ?        00:00:00 [kthreadd]
root         3     2  0 12:07 ?        00:00:00 [rcu_gp]
root         4     2  0 12:07 ?        00:00:00 [rcu_par_gp]
root         6     2  0 12:07 ?        00:00:00 [kworker/0:0H-kb]
root         7     2  0 12:07 ?        00:00:00 [kworker/u4:0-ev]
root         8     2  0 12:07 ?        00:00:00 [mm_percpu_wq]
root         9     2  0 12:07 ?        00:00:00 [ksoftirqd/0]
root        10     2  0 12:07 ?        00:00:00 [rcu_sched]
root        11     2  0 12:07 ?        00:00:00 [migration/0]
root        12     2  0 12:07 ?        00:00:00 [idle_inject/0]
root        14     2  0 12:07 ?        00:00:00 [cpuhp/0]
root        15     2  0 12:07 ?        00:00:00 [cpuhp/1]
root        16     2  0 12:07 ?        00:00:00 [idle_inject/1]

These represent the column:

  • UID: The process owner user ID.
  • PID: The process ID.
  • PPID: Parent process ID.
  • C: The number of children the process has.
  • STIME: Start time of the process.
  • TTY: The console name of the user who started.
  • TIME: The CPU processing time used.
  • CMD: The command name or process name

 

Killing a process

To kill a process, simply run the kill followed by the process ID ( PID):

Example:

sudo kill 33345

To kill a process by name, use the pkill command follow by the process name:

Example:

sudo pkill firefox

You can also use the killall command to kill all the process along with its child processes

sudo killall firefox

That’s it!

Congratulations! You have learned how to use the ps command on Ubuntu Linux

You may also like the post below:

Setup eduTrac SIS LMS on Ubuntu 18.04 | 16.04 with Nginx

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.