Ubuntu – Difference between ps -aux and ps aux

command lineps

What is the difference between ps -aux and ps aux? I wonder it's more than a mere matter of syntax and "portability". Which one is better to use in Ubuntu?

Despite there are some similar question, I'm interested in this specific difference.

Best Answer

BSD and AT&T developed incompatible versions of ps. The options without a leading dash are the BSD style while those with a leading dash are AT&T Unix style.

The ps man page has this to say too:

Note that "ps -aux" is distinct from "ps aux". The POSIX and UNIX standards require that "ps -aux" print all processes owned by a user named "x", as well as printing all processes that would be selected by the -a option. If the user named "x" does not exist, this "ps" may interpret the command as "ps aux" instead and print a warning. This behavior is intended to aid in transitioning old scripts and habits. It is fragile, subject to change, and thus should not be relied upon.

Linux opted to support both. ps -au{user} will error out if you provide a non-existing user. See:

$ ps -autest
error: user name does not exist

 ps [options]

 Try 'ps --help <simple|list|output|threads|misc|all>'
  or 'ps --help <s|l|o|t|m|a>'
 for additional help text.

For more details see ps(1).

Ubuntu/Canonical opted to show an error. Debian opted to give the same output to both ps -aux and ps aux. All in all, pretty confusing. But as stated: this is/was to make scripts compatible. And you can use what you feel happy with.