How to tell `ps` to use all available columns

ps

To specify columns, I can use ps's -o option:

ps -o pid,cmd

How can I tell ps to output all of its available columns?

Best Answer

ps is a very system dependant command. So the answer will depend on the variant of Unix you're using.

With the ps from procps-ng version 3.3.3 on Linux:

ps -Ao "$(ps L|cut -d' ' -f1 | grep -vx thcount)" | less -S

(for some reason thcount appears in the list of known fields but is not accepted as argument to -o. nlwp is OK though).

You'll get a lot of duplication since many of those fields are aliases for the same thing (or different ways to express it. For instance, you don't really need start once you've got lstart).

For the column headers to display the field selector instead of the normal heading (to help you refine which column you do want):

ps -Ao "$(ps L|sed -n '/thcount/!s/\([^ ]*\).*/\1=\1/p')" | less -S

The fields specified by POSIX are args, comm, etime, group, nice, pcpu, pgid, pid, ppid, rgroup, ruser, time, tty, user and vsz. So you can use

ps -Ao args,comm,etime,group,nice,pcpu,pgid,pid,ppid,rgroup,ruser,time,tty,user,vsz

For a command that should works across all compliant systems.

Related Question