When running ps with the -f option in PuTTY (to see the command corresponding to each process), lines which are longer than the terminal width are not fully visible (they are not wrapped on multiple lines).

How can I force line wrapping so that I can see the full commands (on multiple lines, if necessary) when running ps -f?

  • Not an answer, but if I run ps -f in shrinked terminal emulator, output is wrapped on multiple lines. What terminal are you using? – MatthewRock Sep 14 '15 at 8:43
  • 1
    This could be a duplicate of: stackoverflow.com/questions/2159860/… – tommygun Sep 14 '15 at 8:45
  • @MatthewRock I use PuTTy here, do you think this is specific to it? – sdabet Sep 14 '15 at 8:46
  • 1
    @Tonsenson can't close as a cross-site duplicate. – muru Sep 14 '15 at 9:09
  • 1
    @fiddler ah, we can't migrate old questions without moderator intervention, and even then it's not recommended: meta.stackexchange.com/questions/8004/… – muru Sep 14 '15 at 9:31

If you have a POSIX-conforming ps implementation, you may try

ps -f | more

Note that we¹ recently changed the behavior and if you have an implementation that follows POSIX issue 7 tc2, you may try:

ps -wwf | more

¹ We being the people who have weekly teleconferences to discuss the evolvement of the POSIX standard.

  • 1
    ps -wwf works just fine. – sdabet Sep 14 '15 at 9:28

For simplicity, try this: ps auxfww


I've probably found the answer for your question on Stack Overflow. In the words of Dennis Williamson:

It is likely that you're using a pager such as less or most since the output of ps aux is longer than a screenful. If so, the following options will cause (or force) long lines to wrap instead of being truncated.

ps aux | less -+S

ps aux | most -w If you use either of the following commands, lines won't be wrapped but you can use your arrow keys or other movement keys to scroll left and right.

ps aux | less -S # use arrow keys, or Esc+( and Esc+), or Alt+( and Alt+)

ps aux | most # use arrow keys, or < and > (Tab can also be used to scroll right) Lines are always wrapped for more and pg.

When ps aux is used in a pipe, the w option is unnecessary since ps only uses screen width when output is to the terminal.

(Note: this applies to non-embedded Linux, the ps utility on other Unix variants may work differently.)

  • @muru hope this is now looking better. Thanks for clearing all up! – tommygun Sep 14 '15 at 9:28
  • And sorry for causing the mess. – MatthewRock Sep 14 '15 at 9:28
  • 1
    Your answer only applies to /usr/ucb/ps and even with this program you would need ww as /usr/ucb/ps limits the output width to 80 if the output is a pipe. For the POSIX standard ps, see my answer. – schily Sep 14 '15 at 11:49
  • 1
    @schily This answer is perfectly correct for the usual ps command on non-embedded Linux, which is what a majority of readers here have. – Gilles 'SO- stop being evil' Sep 14 '15 at 20:57
  • 1
    But the OP did not set /linux as tag. – schily Sep 14 '15 at 22:13

There is also another simple solution:

echo "$(ps afx)"
  • or just ps afx – nyxee Jan 26 '17 at 3:16
  • 1
    only "ps fax" will cut of after certain amount of characters (i guess 72 standard terminal length) the echo "$(your command)" syntax is for not cutting it off – cinatic Feb 1 '17 at 10:33
  • 1
    Thanks for that. Now, the command behaves completely differently on MacOS (I hear its based on BSD) and Ubuntu (Linux). Linux isn't showing any difference in when u echo or not. But, MAC OS X is printing as much as the terminal can show. I'm using iTerm2 and zsh. MAC doesn't allow the --f option. – nyxee Feb 22 '17 at 8:10

The command for MacOS is slightly different echo "$(ps aux)"

  • You don't want to pass it through echo unnecessarily. Notice also that several other answers already mention ps aux in some way. I would suggest comments or edits on those existing answers to point out that they're good for MacOS (which is what I assume you meant). – Jeff Schaller Jun 7 '19 at 19:08

Or you could do

IFS='$';for line in $(ps axf); do echo $line; done
  • I am curious, why are you setting IFS to $? – AdminBee Feb 20 '20 at 13:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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