NOTE: Assuming you have this version of top
(procps). You can check with this command:
$ top --version
top: procps version 3.2.8
usage: top -hv | -bcisSH -d delay -n iterations [-u user | -U user] -p pid [,pid ...]
procps is often the version of top
included with Fedora/CentOS/RHEL and other variants.
Changing columns
If you look in the man page for top
you'll see a section titled: "2b. SELECTING and ORDERING Columns". There are keyboard shortcuts for toggling visibility for the different fields/columns.
For example:
f,o . Fields/Columns: 'f' add or remove; 'o' change display order
F or O . Select sort field
<,> . Move sort field: '<' next col left; '>' next col right
You can use the key f while in top
to get to a secondary screen where you can specify which columns should be toggled visible or not:
For example:
Current Fields: ANOPQRSTUVbcdefgjlmyzWHIKX for window 3:Mem
Toggle fields via field letter, type any other key to return
* A: PID = Process Id * W: S = Process Status
* N: %MEM = Memory usage (RES) * H: PR = Priority
* O: VIRT = Virtual Image (kb) * I: NI = Nice value
* P: SWAP = Swapped size (kb) * K: %CPU = CPU usage
* Q: RES = Resident size (kb) * X: COMMAND = Command name/line
* R: CODE = Code size (kb)
...
There are more, these are just a sample. When you're done toggling the columns the way you want, use the Esc to get out of the selection screen.
Saving configuration
You can use the Shift+W to save your changes so they're the defaults:
W Write configuration file
The file is stored here, $HOME/.toprc
, and looks like this:
$ more .toprc
RCfile for "top with windows" # shameless braggin'
Id:a, Mode_altscr=0, Mode_irixps=1, Delay_time=1.000, Curwin=2
Def fieldscur=AEHIoqTWKNMBcdfgjpLrsuvyzX
winflags=129016, sortindx=19, maxtasks=0
summclr=2, msgsclr=5, headclr=7, taskclr=7
Job fieldscur=ABcefgjlrstuvyzMKNHIWOPQDX
winflags=63416, sortindx=13, maxtasks=0
summclr=6, msgsclr=6, headclr=7, taskclr=6
Mem fieldscur=ANOPQRSTUVbcdefgjlmyzWHIKX
winflags=65464, sortindx=13, maxtasks=0
summclr=5, msgsclr=5, headclr=4, taskclr=5
Usr fieldscur=ABDECGfhijlopqrstuvyzMKNWX
winflags=65464, sortindx=12, maxtasks=0
summclr=3, msgsclr=3, headclr=2, taskclr=7
See section 5 of the man page for more details, "5. FILES".
Best Answer
top -bcn1 -w512
The elegant solution is to use the option
-w [number]
. According to the man page, the maximum width is 512 characters, so you will need a different solution for anything exceeding that. Presumably you also want to see the full length of the commands, so use the-c
option. We need to runtop
in "batch mode",-b
, or it will continue to cut off the commands with a "+". Batch mode kind of makes a mess because it prints out all the jobs every second, so we can use the-n1
option to print out just one instance.See the man top page for more information.