Saturday, February 12, 2011

Getting The Full Result from "ps"

Hi,

How do I get the full width result for the *nix command "ps"?
I know we can specify something like "--cols 1000" but is there anyway I can the columns and just print out everything?

  • Try ps -w -w aux. The -w option sets the output to wide, and doing it twice makes the width unlimited. The "aux" part makes it show more information, and is (afaik) pretty standard mode to use. This is of course platform-dependant, the above works with procps version 3.2.7 on Linux.

    Chris Jester-Young : There's nothing magical about "aux"; they're simply the 'a', 'u', and 'x' options specified together. So, you can merge the two 'w' options in too. :-)
    unwind : Ah, yes, true of course. I guess it's just my standard incantation, to treat "aux" as an argument more than an option. Thanks, though.
    From unwind
  • Specify the w option twice, if you're using BSD-style ps. e.g., ps auwwx. A different set of options apply when using System V ps.

    Max Howell : This is a comment, not an answer, surely.
    Chris Jester-Young : It's an answer now!
  • There are two different option syntaxes for ps; the standard POSIX one based on SysV, and the BSD one. GNU ps, as used on linux, supports both, which it can do because the POSIX options have dashes in front and the BSD ones don't, as well as some of it's own options in the normal GNU --long-option-name style.

    Anyway, to get all processes in POSIX style is -e, in BSD it's ax (a includes other user's processes, x includes processes without a controlling terminal i.e. daemons).

    There is no single option that will make it include all the columns. There are a huge number of possible columns. The POSIX options -f, -F and -L all cause it to show different sets of extra columns, as does the BSD option u (hence the "ps aux" mentioned in another answer is a very common command).

    If you really want more columns than that you have to name explicitly which ones you want, using the -o (or o) option. See the man page for a list. There's about a hundred different names you can use, but some of them are duplicates, and others display the same info in different ways.

    ephemient : Accurate but answering the wrong question...
    Mark Baker : I read the bit about "printing out everything" to mean they wanted all the possible columns in the output, so I answered that. I agree the bit about getting all processes was the wrong question.
    From Mark Baker

0 comments:

Post a Comment