23

Following command outputs only first 25 characters of the process name (cmd) on the screen. How do I get it to display the full process name?

 ps -eo pid,cmd,etime
1

3 Answers 3

19

The simplest thing you can do is swap the order of outputs: if cmd is last, it will be extended to the full width of the terminal:

ps -eo pid,etime,cmd

If that's still not sufficient, you can add a -w (wide) output modifier

ps -ewo pid,etime,cmd

An additional w gives even wider output

ps -ewwo pid,etime,cmd

(In both of these cases, the output may be wrapped by the terminal.) If you really must have the original field order, then you can specify an explicit width for the cmd field using the syntax field:width e.g.

ps -eo pid,cmd:80,etime

This can be combined with the -w flag(s) if necessary e.g.

ps -ewo pid,cmd:160,etime

The width of a particular output column can also be forced wider by using a longer header string e.g.

ps -eo pid,cmd=my_very_very_very_long_command_that_I_want_to_see_more_of,etime
1
  • 1
    It depends on ps implementation. E.g., the BusyBox ps does not implement -w, and, AFAICT, always truncates. (And in that case, it seems like one must either parse /proc themselves, or find a better ps.)
    – Thanatos
    Jan 10, 2023 at 21:14
7

Pipe the output to cat.

ps -eo pid,cmd,etime | cat
2
  • 2
    of course this is the answer
    – ClintM
    May 23, 2023 at 23:17
  • This definitely isn't the answer. 'cmd' is still truncated.
    – Lethargos
    Sep 20, 2023 at 17:52
2
ps -A  -o pid,user:20,%cpu,%mem,comm,args
2
  • 1
    Can you add some comments to your proposed solution, please?
    – Marco
    Dec 7, 2018 at 10:45
  • ps -A -o ppid,pid,user,%cpu,%mem,args works on MacOSX — user:20 is an error and comm,args is redundant. It seems essential for args to be last.
    – Devon
    Mar 2, 2020 at 12:08

You must log in to answer this question.

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