Categories
Linux Tutorial Series

Linux Tutorial Series – 106 – Viewing threads

Here is the video version, if you prefer it:

To view threads you are currently running, you can either execute ps m or execute top, then press H to see a list of all the threads. (Ward, 2014)⁠ Examples for both:

mislav@mislavovo-racunalo:~$ ps m

PID TTY STAT TIME COMMAND

5008 pts/1 - 0:00 bash

- - Ss 0:00 -

6695 tty2 - 0:00 /usr/lib/gdm3/gdm-wayland-session /usr/bin/gnome-sess

- - Ssl+ 0:00 -

- - Ssl+ 0:00 -

- - Ssl+ 0:00 -

Where there is a dash instead of a PID, that’s a thread.

top - 20:44:14 up 96 days, 3:05, 1 user, load average: 0.58, 0.62, 0.62

Threads: 864 total, 1 running, 862 sleeping, 0 stopped, 1 zombie

%Cpu(s): 3.5 us, 4.1 sy, 0.0 ni, 92.4 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st

MiB Mem : 7853.8 total, 1109.6 free, 4105.2 used, 2639.0 buff/cache

MiB Swap: 8066.0 total, 6836.9 free, 1229.1 used. 3052.6 avail Mem

I got to this by pressing H after I ran top.

Side note: I don’t think you will ever have to mangle with threads (I haven’t), but pays to know what they are and how to view them.

Hope you learned something useful!

References

Ward, B. (2014). How Linux Works: What Every Superuser Should Know (2nd ed.). No Starch Press. Pages 177-178

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 *