3

EDITED:

  1. These are the the only most commonly used (and important) ps command options I've come across so far: $ ps ux, $ ps au, $ ps aux, $ ps U aahan, $ ps uU aahan So, is that all, or am I missing 1 or 2?

  2. Can someone tell me the difference between $ ps au and $ ps aux?

its_me
  • 13,959
  • These are some common ones I've been able to find (though I don't know if I'll ever be using them - - a newbie here):

    $ ps ux, $ ps -aux, $ ps U aahan, $ ps uU aahan

    – its_me Aug 05 '11 at 21:53
  • 1
    For the sake of clarity in terminology, it seems you are talking about the most commonly used options or sets of options to the one ps command (multiple versions of ps exist but that's probably not what you are after). – jw013 Aug 05 '11 at 21:54
  • right, that's probably the term to use. Edited my question. – its_me Aug 05 '11 at 21:56
  • looks like nobody really uses ps? So, there's probably a command that does the same and does it better, I guess? – its_me Aug 05 '11 at 22:16
  • 2
    Questions asking for a long list of answers, like this one, do not work well on Stack Exchange, where we expect each answer to make an attempt at being the best answer. Please read the [faq#dontask]; you're essentially asking “what are your favorite ps options”. You can see an example of such a question here, left over from our early days when we didn't quite realize what a mess the answers would become. – Gilles 'SO- stop being evil' Aug 05 '11 at 22:40
  • 2
    The complete list of possible flags are documented in the man pages. If you want to know the difference between ps au and ps aux look up what the x flag does in the man page. If there is something you don't understand after that, then ask here. What options you use is less about "favorites" or "frequently used" and more about what YOU need to see. – Caleb Aug 05 '11 at 22:57

2 Answers2

4

To understand combination of options, you need to understand the options themselves. To get a glimpse, try ps --help. To see explanation of every option, see ps manual (man ps, but that's a reading for a very long evening).

There are several styles of passing options to command in Linux. It depends on the program, which style it understands. One of most common style is using single-letter options and passing them using - (dash), when it usually does not matter on order of options (e.g. ls -a -l is the same as ls -l -a -- "list, a-ll items using l-ong format") and they can be concatenated to use with one dash (so ps -al or ps -la is still the same as above).

Besides one-letter options, there are also one-letter parameters, which need their value, which, in case of ps -u aahan means "processes of u-ser aahan. (This is the exception to option grouping: such option has to be the last one in the group to prevent misinterpretation.)

Then there are long options like --help, which sometimes have obvious meaning, sometimes not, but it's another story.

ps, however, is unfortunately using some conglomerate of more styles: with the dash (command -o, which I believe iis called "linux style") or without the dash (command o, which I believe comes from BSD). This makes usual ps commands look a little confusing, but once you read ps --help, you should be able to recognize them.

To make it even more confusing, there are also several versions of ps. (The OSX ps has different options as Linux ps, for example.)

Well, I use ps -A (list all processes) most of the time, it's just because I didn't need any other yet. (Or, more probably I didn't know I needed them... :D).

My advice: Get to understand the basic ones, use them, and if ps does not answer your question: explore, study, experiment...

Alois Mahdal
  • 4,440
  • 1
    The '-X' style in ps came from SysV, I believe, which became the POSIX style; the gnu version just combined the different styles into one command. – Arcege Aug 06 '11 at 00:41
3

My most common is ps xuwww which shows the complete width of the command. Another common one I use is ps xo pid,ppid,cmd which just shows the process id, the parent's process id and the command string.

You ask the difference between ps au and ps aux. The x options shows processes that are not attached to a terminal; generally daemons or disowned, background processes. This is very useful when you want to check the status of a daemon (like tomcat or httpd) or the status of an application started from the window manager (which will not have a terminal associated with it).

Arcege
  • 22,536