Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

The "command" column gets truncated by the width of the screen and I am unable to see the last part of it.

I have tried to reduce the font size so I can see a longer part of the command line but it still won't do.

share|improve this question

migrated from stackoverflow.com Jan 27 '12 at 2:13

This question came from our site for professional and enthusiast programmers.

    
What command generates your output? –  Tichodroma Jan 26 '12 at 13:28
    
I know this doesn't directly answer your question, but I'd look at htop for a much nicer interface to top. It will let you scroll with the arrow keys. –  Daniel Arndt Jan 26 '12 at 13:29
    
Can you clarify why didn't reducing font size work? –  Stephen Quan Jan 27 '12 at 13:05
    
it works but not enough for me to see the whole line.. the command line is rather long –  sureshvv Jan 30 '12 at 6:11

4 Answers 4

up vote 2 down vote accepted

As Daniel Arndt said, you can also use htop instead of top. It's available on all distro nowadays, and it provides better numbers (especially for memory usage)

It is also far easier to use and nicer to see, even if it's limited to terminal's colors. You can scroll to the right in order to see the full command, for instance, or you can kill a process with a simple F9. You can also see full tree with 't' key.

share|improve this answer
    
This does not answer the question but is a suggestion for a different program. htop is a nice program indeed but the question was about top's output. Please remain on topic. –  drumfire Dec 27 '13 at 20:19
    
@drumfire offering alternatives is perfectly valid and on topic. This should be obvious by the fact that the OP accepted this answer almost three years ago. –  terdon Dec 28 '13 at 1:06

The command field is by default truncated automatically for better reading.

You need to run

top -c

to show full command then depending on your console window's capabilities you would be able to scroll to right and see full command.

share|improve this answer
    
That just displays the full command line by default - or actually whatever can be made visible in one line. I don't see any scrolling ability. Are you saying I just have to set my window to a larger width? –  sureshvv Jan 26 '12 at 14:38
    
Yes, that to begin with. What type of window are you using? is it a Putty, Dos command terminal, Gnome terminal ? any of these will allow you to scroll horizontally. –  ring bearer Jan 26 '12 at 14:43

This is hacky, but you can modify the behavior by adjusting the $COLUMNS and $LINES shell variables before launching top:

export COLUMNS=$((COLUMNS*2))
export LINES=$((LINES/2))
top

This will convince the shell that you have twice as many columns to write to (and half as many rows, to offset this). If you're using bash, you can run shopt -s checkwinsize beforehand, which will tell it to re-compute those values once top exits. Otherwise, you can just backup/restore those values (or just resize the window).

share|improve this answer

You could design a batch screen that includes top -b -n 1 and ps, for example:

while (true)
do
  clear
  top -b -n 1
  ps
  sleep 5
done

This will handle displaying:

  • PID
  • CPU
  • Untruncated command line
share|improve this answer

Your Answer

 
discard

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.