According to the man page of ps command, the x flag

Lift the BSD-style "must have a tty" restriction, which is imposed upon the set of all processes when some BSD-style (without "-") options are used or when the ps personality setting is BSD-like. The set of processes selected in this manner is in addition to the set of processes selected by other means. An alternate description is that this option causes ps to list all processes owned by you (same EUID as ps), or to list all processes when used together with the a option.

and for -a flag:

-a Select all processes except both session leaders (see getsid(2)) and processes not associated with a terminal.

In my Ubunbtu 16.04 laptop:

$ ps -a | wc -l
$ ps -x | wc -l

Does this mean I have 132 processes associated with a terminal (and not session leaders at the same time)? How can this be since I have only one terminator instance open (and this with only one terminal window running just some commands)?

Can anyone elaborate a bit on the difference among -x and -a flags?

We all know that to get all the processes running we need to combine those two but what is their exact difference?

  • Did you mean the BSD option a or the UNIX option -a. On my system, the former lists all the processes listed by the later, and also session leaders. – Stefan Hamcke Nov 12 '18 at 19:25

There seems to be some confusion between Unix-style and BSD-style options. The options involving a and x are -a (Unix-style), a (BSD-style), and x (BSD-style); there is no -x. Since you used the tag I’ll concentrate on the ps implementation commonly found on Linux distributions.

By default, ps only lists the invoking user’s processes which are attached to the current terminal.

a lifts the “invoking user” restriction: ps a lists all users’ processes which are attached to a terminal. x lifts the “attached to a terminal” restriction: ps x lists all the invoking user’s processes. ps ax lists all processes.

ps -a lists all users’ processes which are attached to a terminal and aren’t session leaders.

ps -ax is equivalent to ps ax: the presence of the -x flag, which is BSD-style, causes ps to interpret all flags in BSD style. Likewise, ps -x is equivalent to ps x.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.