This is a combination of several BSD-style options (all of which are in the manual page,
a: include processes from other users
x: include processes with no terminal
u: show user-oriented information fields
w: wide output (132 columns instead of 80)
f: "forest": tree view of processes
w: even wider output (no limit at all)
In other words, it simply shows currently running processes.
However, if you see old processes there, check their "STAT" field – if it says
Z, the process has exited but its parent hasn't "reaped" it yet; the process is a "zombie". This usually indicates that the parent process is either slightly buggy, or has hung/crashed.
Also, note that not all operating systems accept these options. On SysV it might be
ps axuwfw | grep -v grep | grep -i screen
| is a pipe. It redirects one command's output to the other's input. This should make it more obvious that the above is not just one weird magical command; it is three commands connected.
The first command,
ps axuwfw, was already explained.
grep, is for searching/filtering text.
grep foo would only print input lines that contain the text "foo". With the
-v option, the second command –
grep -v … – does the opposite – prints lines that do not match. (Again, refer to
man grep or
This particular invocation is necessary because all processes in a pipeline run at the same time, so the
ps… would show all
grep… processes – and
ps axu | grep screen would cause the
grep… to also match its own entry in addition to the desired ones. So a second
grep… is added to explicitly ignore lines that have "grep" in them.
(Of course, there are better tools, like
pgrep -alf screen, but many people still use this kind of
ps|grep|grep… pipeline just because it's easy to combine knowing just
The third command,
grep -i screen, again just extracts lines that contain "screen".
As described in both the manual page and the
grep --help output, adding the
-i option makes the search case-insensitive, so it also outputs lines that have "Screen" or "SCREEN" in them.
In short, the full command just prints those
ps… lines that talk about the "screen" program.
"The above two commands return 431 and 7 in the example from here…"
They don't. They return information about processes named "screen" or "tmux". The number given in the example is the count of processes returned.
The slideshow's author didn't include the full output (which isn't really relevant); they only included the total counts as a summary, demonstrating that there are 60 times more "screen" users than "tmux" users.
If you want the command to actually count lines for you, you can a) add the
-c (count) option to the last
grep… command, or b) pipe it through
| wc -l. (Either works.)
"…but in my system it returns garbage."
It returns some previously ran older makefile output and truncated process tree
That's not garbage – it's exactly the output you asked it for.