Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

It only shows the first 15 characters from /proc/pid/stat. But "ps -w pid" shows wide output. Why? Is this a bug? Thanks.

share|improve this question
Don't mistake BSD options for SystemV options. "ps awx" is BSD, "ps -ef" is SystemV. – Paul Tomblin Apr 8 '11 at 14:25
I did not. I mean 'ps -e -w' by 'ps -ew'. – fossilet Apr 8 '11 at 14:36
Yes, but "ps -ew" has the SystemV format for wide display, which isn't as wide as the BSD wide display. In Gnu ps, "ps -w" gives you the same SystemV (not very) wide display. On some systems, like Solaris, they try to allow both formats even if you include the "-", and so it can't tell if you want the SystemV or the BSD wide, so it gives you the BSD wide. But once you include the "e", you're definitely in the SystemV land. – Paul Tomblin Apr 8 '11 at 14:43
I am using Ubuntu 10.10. I am using the latest version 3.2.8 from Ubuntu repo. – fossilet Apr 8 '11 at 15:47
I am reading the source code dealing with option parsing ps/parser.c in the source tar ball. It is more than 1000 lines of C code. If I am good at C, I would remove the messes. I hope someone could write a new parse. We do not need those exra useless messy options. – fossilet Apr 8 '11 at 15:50

I don't think "wide output" means what you want. I created a script named and get the following

$ ps -w
27848 pts/3    00:00:00 foo_foo_foo_foo

$ ps a
27848 pts/3    S      0:00 /bin/bash ./

$ ps -f
username 28049 26422  0 09:48 pts/3    00:00:00 /bin/bash ./

The only thing w and -w seem to do is let lines wrap if I shrink the window so it won't fit on a line:

$ ps w
28429 pts/3    S      0:00 /bin/bash ./foo_foo_foo_foo_foo_foo_foo_foo_foo_foo_foo_fo
share|improve this answer
I use PID as an argument:$ ps -w 5656 PID TTY STAT TIME COMMAND 5656 pts/11 T 0:00 /bin/bash ./ $ ps 5656 PID TTY STAT TIME COMMAND 5656 pts/11 T 0:00 /bin/bash ./foo_foo_foo_foo_foo_foo_foo_foo_foo_foo_f – fossilet Apr 8 '11 at 15:17
I hate this command. The options are the worst I have ever seen on Linux. There are a lot of people asking about its options. why do not the people at GNU write a pure GNUish one? I do not want to waste time any more on this commands' options and the details. I hate it, for long. – fossilet Apr 8 '11 at 15:20

You can apparently do it by explicitly listing the fields:

ps -ew -o pid,tty,time,cmd

Or, BSD-style:

ps awxo pid,tty,time,cmd

Probably useful in a script, not so useful for the command line. Unless you make an alias.

share|improve this answer
PS - I agree that ps -ew should look like ps -ew -o pid,tty,time,cmd by default. Maybe you should submit a bug! – Cakemox Apr 9 '11 at 19:43
It's not just a bug, it's a design fiasco. I've set up a project called GNU ps to make the options better at I've removed the support for BSD options. Please take a try, though there are much to be done. – fossilet Apr 10 '11 at 5:22
I understand your frustration, but it'll be extremely difficult to create a drop-in replacement for ps since it is well-established in its current form. Dropping support for BSD options will break many, many existing scripts. Keep that in mind. – Cakemox Apr 10 '11 at 5:25

Try ps -efww .

On Debian/Ubuntu this gives you :

   -w              Wide output. Use this option twice for unlimited width.
share|improve this answer
It doesn't work for 'ps -ew'. You must include f for w to work. It is not documented in the man page. – fossilet Apr 8 '11 at 15:45
@fossilet What's the use case that demands -e and not -ef ? Or are you just attempting to verify a bug or undocumented requirement? – belacqua Apr 8 '11 at 15:55
I expect this vital utility on Linux should have clear behaviors like most of the other ones. But it fails. See how well the GNU tools are done. – fossilet Apr 8 '11 at 15:59

Thank you for all the comments above which enlighten me.

ps -ew contains no BSD options, so I get the default output, which get the process name from /proc/<pid>/stat, which is no more than 15 characters.

The -w option is indeed in effect, it does show wide output. If I shrink the window very narrow, ps -ew will try to wrap the lines so that I still get the full 15 characters in COMMAND column. But with out -w, like ps -e, long lines are are not seen, but they are still there since I can not see them but can grep them.

In a 35 columns terminal (some output snipped):

$ /bin/ps -e
  PID TTY          TIME CMD
22125 ?        00:00:00 telepathy-s
22127 ?        00:00:00 telepathy-g

$ /bin/ps -e | grep gabbl
22127 ?        00:00:00 telepathy-gabbl

As of ps -w <pid>, I find the answer from parser.c of procps source code. It implies BSD style output if there are PID arguments, which is not said in the man page:

   if((tmp>='0') && (tmp<='9'))   return ARG_PID;
   case ARG_PID:
          prefer_bsd_defaults = 1;
          err = parse_trailing_pids();

So ps -w <pid> will show BSD-style output, which will show command args (COMMAND) instead of the executable name (CMD). -w is in effect similar to the above example.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.