Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

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

Writer Matthew Martinez

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

3

2 Answers

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).

2

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.
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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