ps: That other process tool

I spent way too much time talking about factor, so I’m going to clip ps short. Which probably isn’t fair, since ps has an actual measure of use, while factor was … just for fun.

Here’s what it does, when bidden:

kmandla@6m47421: ~$ ps
  PID TTY          TIME CMD
19982 pts/1    00:00:00 bash
19983 pts/1    00:00:00 ps

That seems a little sparse. Let’s look around for some better uses. How about …

kmandla@6m47421: ~$ ps -a
  PID TTY          TIME CMD
  189 tty1     00:00:00 startx
  206 tty1     00:00:00 xinit
  211 tty1     00:00:03 blackbox
  216 tty1     00:01:28 urxvtd
20000 pts/1    00:00:00 ps

Better. Let’s add “user format.”

kmandla@6m47421: ~$ ps -au
kmandla    184  0.0  0.0   5528  1572 tty1     Ss   07:09   0:00 -bash
kmandla    189  0.0  0.0   5464  1632 tty1     S+   07:09   0:00 /bin/sh /usr/bin/startx
kmandla    206  0.0  0.0   3812  1164 tty1     S+   07:09   0:00 xinit /home/kmandla/.xinitrc -- /etc/X11/xinit/xserverr
kmandla    211  0.0  0.2  12428  4336 tty1     S    07:09   0:03 blackbox
kmandla    216  0.2  0.6  24228 12936 tty1     S    07:09   1:28 urxvtd -q -o -f
kmandla   5778  0.1  0.3  11956  7644 pts/2    Ss+  13:00   0:13 vim
kmandla   8516  0.1  0.3  20804  6288 pts/0    Ss+  13:45   0:06 mocp
kmandla  19982  0.0  0.1   5516  3348 pts/1    Ss   15:20   0:00 bash
kmandla  20006  0.0  0.1   6148  2840 pts/1    R+   15:26   0:00 ps -au

And that’s probably where I’d stop. ps has a lot more options, but not all of them strike me as … practical, to be honest. Beyond a point, I start grepping through things like ps -A and ps -aux. But you can decide.

ps is in procps in Debian and procps-ng in Arch. And probably in something similar in your system. 😉

9 thoughts on “ps: That other process tool

  1. Theodore

    I use mostly ps -ef for having a glance of which program is using a crapload of CPU and ps aux to investigate memory usage.

      1. Theodore

        ah, you’re welcome! This trick, for me, has a story: it’s the first thing I’ve learnt to use in linux in my first internship some years ago. And maybe it’s the only useful thing I still carry from that experience… but that’s another story. 😀

  2. Pingback: Links 14/8/2014: Kernel Summit Coming, KMix on KDE Frameworks 5 | Techrights

  3. Theodore

    Well depends by the opt: ps e prints the processes of the user with their env vars, ps -e prints every process running in the OS, by any user, ps a prints every process launched in a terminal, ps -a prints every process except session leaders (shells). Options without leading hyphens are BSD flags, and those that carry hyphens are UNIX opts. And the opts that don’t differ at all as flags or opts are very few!

    May the gods burn the soul of sw devs in the heatest of hells! -.-

  4. Pingback: recap: Everything about everything from everything, prepacked | Inconsolation

  5. Georg

    TL;DR: ps -aux | grep -q [c]upsd

    And if you want, say, use grep -q on the ps output in a script just remember to put any letter of the program name in square brackets to make it not find the grep command itself.

  6. Pingback: ips: Intelligent process monitoring | Inconsolation

Comments are closed.