What is the difference between the processes listed by ps and ps -A ?

  • 1
    Did you even attempt to read the ps man page? “-A: Select all processes” – Giacomo1968 Apr 15 '15 at 18:48
  • 1
    @JakeGould While I agree that that's a good start, to the askers defence, the manpage is a bit ambiguous when it comes to its definition of "all processes" – Jarmund Apr 15 '15 at 18:57
  • JakeGould: Yes I read it. Jarmund: Exactly .. It is not clear enough. – faressoft Apr 15 '15 at 19:28

without the -A, ps will only print the processes belonging to the current session. Think of it like "absolutely everything". On a related note -a does the same thing, but restricting it to the session-owner (username).

  • Why does ps -a list different processes than ps x for GNU ps? I would think both would restrict it to the current user. – Josiah Yoder Jul 26 '19 at 21:25
  • According to the man page, ps -a does not include session leaders, whereas ps x does. – Josiah Yoder Jul 26 '19 at 21:42

The GNU ps command suffers from a severe case of multiple personality disorder. So it is no wonder that its manual page is confusing. Perhaps a look at the BSD manuals might help. After all, this question is tagged .

The operation of BSD ps is fairly straightforward when one bears two things in mind:

  • Processes are selected for display using two basic filters. Those filters are on by default and command line options turn them off. Plain unadorned ps is thus filtered through both.
  • BSD syntax goes back a long way. Although the modern BSDs use getopt and the convention of options prefixed by a minus sign, the options and behaviour relevant here are much the same as from 30 years ago.

That behaviour is this:

  • The -a (historically a) option turns off all "selector" filtering.
    • The various other command line options specify selectors: -U selects by UID, -t by controlling terminal name, -p selects by process ID, and so forth. All of these are bypassed by -a.
    • If no selectors are explicitly supplied, the default selector is to only display processes running with the same effective UID as the user who invoked ps. This default selector is the historic filter that this option turns off.
  • The -x (historically x) option turns off the restriction that ps only display processes that have a controlling terminal.

Historically, BSD ps did not have an A option. But modern BSDs implement an -A option, also usable as A, for (a degree of) compatibility with the (later) Single UNIX Specification. -A is simply the same as using both -a and -x: it turns both restrictions off, leaving one with all processes, unfiltered.

OpenBSD and NetBSD document the -A option, in NetBSD's case explicitly as -a -x. FreeBSD does not, but a comment in the source code states that it is there as an intentionally undocumented SUSv5 compatibility option.

Further reading

  • ps 1983-04-13. 4.2BSD Manual pages.
  • ps OpenBSD Manual pages.
  • ps 2009-10-22. NetBSD Manual pages.
  • ps 2014-08-07. FreeBSD Manual pages.
  • To get the BSD behavior with GNU ps (the default ps in ubuntu), leave off the - in the arguments: ps a, ps x, ps ax, or ps -A (that last one you must leave the - on). – Josiah Yoder Jul 26 '19 at 21:22

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.