Categories
Linux Tutorial Series

Linux Tutorial Series – 99 – The ps command

Here is the video version, if you prefer it:

The ps command is used to display the processes which are currently running. By running ps without any options, you get the processes associated with the current Terminal, as so:

mislav@mislavovo-racunalo:~/Linux_folder$ ps

PID TTY TIME CMD

10653 pts/1 00:00:00 bash

31210 pts/1 00:00:00 ps

PID is process ID. TTY is the controlling terminal associated with the process – this field is irrelevant. TIME is processor time the process is taking up – the more processor time a process takes up, the more demanding it is. CMD is the command with which we started the process; it’s the name of the process, with arguments, if arguments exist. (Shotts, 2019)⁠

ps x gives us all the processes that our current user is running. An example:

mislav@mislavovo-racunalo:~/Linux_folder$ ps x

PID TTY STAT TIME COMMAND

1145 ? Sl 78:18 /usr/bin/gedit --gapplication-service

3350 ? Ss 0:22 /lib/systemd/systemd --user

3351 ? S 0:00 (sd-pam)

3455 ? Ssl 1397:59 /usr/bin/pulseaudio –daemonize=no

...

The new column STAT is short for state. State is the process state – it indicates what the process is doing. The first capital S means that process is sleeping, and that means the process is waiting for input. There are other process states, which you can learn more about by typing man ps and navigating to a section titled PROCESS STATE CODES.

ps aux gives us the processes of all users. Its sample output is:

mislav@mislavovo-racunalo:~/Linux_folder$ ps aux

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND

root 1 0.0 0.0 170896 5584 ? Ss 2019 26:40 /sbin/init

root 2 0.0 0.0 0 0 ? S 2019 0:01 [kthreadd]

root 3 0.0 0.0 0 0 ? I< 2019 0:00 [rcu_gp]

root 4 0.0 0.0 0 0 ? I< 2019 0:00 [rcu_par_gp]

As you can see here, we can see which user started each process (the column USER). We have a couple of additional columns – %CPU signifies how much CPU (in percentages) the process are using, %MEM is the percentage of RAM the process are using, VSZ is the virtual memory size (think of virtual memory as being as large as your hard drive and RAM size combined), RSS (Resident Set Size) is the amount of RAM the process is using in kilobytes, and START is the time when the process had started.

This is how you can take a look at the processes running in your computer.

Hope you learned something useful!

References

Shotts, W. (2019). The Linux Command Line, Fifth Internet Edition. Retrieved from http://linuxcommand.org/tlcl.php. Pages 135-137

NewsletterUpdates on interesting things I am doing

Subscribe to my newsletter to keep abreast of the interesting things I'm doing. I will send you the newsletter only when there is something interesting. This means 0% spam, 100% interesting content.

Leave a Reply

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