68

When we enter:

ps -f

... the CMD column text doesn't show the full command. Any way to prevent this truncating?

Seems like it's showing the first 80 characters. We are running a fairly log command that has lots of command line switches.


Thanks for the responses.. doesn't seem like any of these do the trick though..

0

8 Answers 8

81

Pipe the result into cat .. that'll ignore your terminal settings.

ps -f | cat
1
  • 2
    I use ps aux before, now ps aux | cat, it's magic.
    – John Lee
    Aug 13, 2022 at 3:48
49

I found this on my FreeBSD's 9 ps man page:

-w Use 132 columns to display information, instead of the default which is your window size. If the -w option is specified more than once, ps will use as many columns as necessary without regard for your window size. Note that this option has no effect if the “command” column is not the last column displayed.

So:

ps auxww

Did what I wanted.

2
  • 3
    Confused why this isn't the most popular answer. May 19, 2014 at 14:03
  • 4
    +1 for not involving any other command. ps -fww (using UNIX options syntax) works too.
    – Melebius
    May 14, 2015 at 5:52
13

If /usr/ucb dir exists then you may try following command

/usr/ucb/ps -auxww | grep java
12

ps detects the size of your terminal window and clips to that.

Solution: don't output directly to the terminal!

ps -f | less
4

man ps:

-w Use 132 columns to display information, instead of the default which is your window size. If the -w option is specified more than once, ps will use as many columns as necessary without regard for your window size. When output is not to a terminal, an unlimited number of columns are always used.

Hence:

ps -f | cat

Works.

2

more works perfectly for me

ps -ef |more
1

As other answers have noted, piping the output to another command (e.g., less or more) or redirecting to a file will usually result in the terminal width being ignored.

However, if that's not working, it might be because the COLUMNS shell variable is being exported into your environment, in which case ps will use that value as the terminal width (ref).

To fix that issue, you can unexport (export -n COLUMNS) or unset (unset COLUMNS) the variable, or pass one of the --cols <n>, --columns <n>, or --width <n> options -- these are all synonyms in the procps-ng implementation of ps that's most commonly used on Linux.

1

Don't forget that -eaf works with normal ps only and not luddite ucb ps.

Ucb ps uses multiple -w options to give you the complete command line.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .