The top/htop command(s)

top and htop are free CLI process viewers. They list the top resource using processes being run.The information includes:

  • PID — Process Id The task’s unique process ID
  • PPID — Parent Process PID (Process ID) of a task’s parent
  • RUSER — Real User NameThe real user name of the task’s owner 
  • UID — User IdThe effective user ID of the task’s owner
  • USER — User NameThe effective user name of the task’s owner
  • GROUP — Group NameThe effective group name of the task’s owner.
  • NI — Nice value The nice value of the task. A negative nice value means higher priority, whereas a positive nice value means lower priority. Zero in this field simply means priority will not be adjusted.

top options:
a : Sort by memory usage This switch makes top to sort the processes by allocated memory
d : Delay time update interval as: -d ss.tt (seconds.tenths)
p : Monitor PIDs as: -pN1 -pN2 … or -pN1, N2 [,…]
u : <somebody> Monitor only processes with an effective UID or user name matching <somebody>.
htop options:
-u –user=USERNAME Show only the processes of a given user
-d –delay=DELAY Delay between updates, in tenths of seconds

Examples:

To run top in batch mode (updating every 3 seconds) and write it to a file in my directory
top -b -d 10 -n 3 >> /home/<user>/top-file

To run htop to get only processes for my user:
htop -u <user>

About vicki

Welcome to the Sovereign Republic of Vickistan. I am the President here. Lucky me! No taxes or laws yet. Lucky you!
This entry was posted in Linux. Bookmark the permalink.