When prompted for the PID to renice, entering any value that isn't a positive integer will exit the renice mode with an error message. Once you enter a PID, however, you are stuck entering a priority; any invalid entry will cause the get_int function to return -1, which will set the priority to -1. The only way to avoid entering a priority is to kill top. Ctrl-C should work. Ctrl-D or enter will cause the niceness to be set to -1.
Source: Procps source code
top -M
sorts by resident memory usage.
M
sort tasks by resident memory usage.
This is the version of top on my system.
top -v
top: procps version 3.2.7
If your Linux distribution supports the -M
flag, you could use it as mentioned here.
However, if your top
doesn't support the -M
flag, you could launch your top
command and get into the interactive mode by typing h to check the sort field. (I assume it is the same across various distributions)
In my system (rather the top
version of my system), I could type F or O to select the sorting field and key Q of my top
version lets me sort on resident memory.
If you want to save your configuration you could do something as mentioned by slm here.
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
Looking at the sources of
top
, it seems that there's a hardcoded maximum of 8 chars:The
fmts
colum is aprintf
format string.%-8.8s
means left padded string of minimum and maximum size of 8.