- top -h for a condensed list of commands,
- man top for a much more verbose explanation of all available options.
- It has a powerful interactive mode You can use a variety of commands in form of just letter key presses to manipulate what you are seeing. Here are a few examples.
- To sort processes by memory usage simply press M (shift-m on the keyboard).
- To sort by CPU usage press P (shift-p).
- You can see a full list of fields by pressing f which will show the fields with their appropriate letter (which you can use to sort by that field).
- With the f key you can also opt to add a new field to display by pressing f and then the letter representing the key. For example if you want to add a code size field (CODE) press f and then r (as shown in the field list).
- You can set the delay time for updates by just pressing s, putting in a desired number of seconds, and pressing enter. It will then update in that number of seconds, but you can update any time you want yourself by pressing the space bar.
- To change the number of processes shown just press n, put in the desired number and press enter.
- You can even kill processes from within top if you have a rogue process or a program of some kind wont quit or some process is using too many resources. To do so press k, enter the PID (Process ID, which you can read in top) of that process and press enter.
- Linux top also supports the cumulative mode which can be simply toggled by pressing S (shift-s).
- Start top with some options already set.
- For example, top -d 5 will cause top to refresh its data every five seconds (equivalent to s and 5 in the interactive mode).
- The top -q will display information without any delay, and run it with highest priority if top is run as a superuser (or root).
- Top can also be started to show only a few updates and then quit automatically. Just run top -n 10, for instance, to have top show 10 iterations of information before quitting.
- Another interesting command line option is top -b which runs top in a batch mode suitable for recording into a text file. Instead of just refreshing information on screen it prints it out in batches every specified number of seconds until all iterations run out (set by -n as mentioned above) or until it is quit. To write it out into a text file called top.txt stored in a local directory just run top -b > top.txt.
- To quit top manually,just press the q key.
Monday, May 2, 2011
Linux Top command - Handy info
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment