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.
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.
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
Usage:
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.
ps -aux but if the user x doesn't exist it falls back to a completely different meaning for those options? That is more confusing than if it just exited with an error. They should force an option to either use the BSD or Unix definition, conditional switching between option definitions based on an error case (non-existent user) seems crazy to me. It seems ps -aux should not be recommended. For people as confused as I am who want to stick with the Unix options, ps -eF provides almost the same information as ps aux (gives proc size instead of virtual size)
– theferrit32
Apr 04 '18 at 17:37
ps aux"? After all, the output ofps -auxis dependent on there being a user namedx. – muru Apr 05 '18 at 06:28ps aux, that's the BSD flavor. – floatingpurr Apr 05 '18 at 09:18ps -efis the correct equivalent using the dash syntax – mbrig Apr 06 '18 at 14:24