Sunday, February 27, 2011

Monitor Processes in Linux

ps aux | less --- display all running process

  • -A: select all processes
  • a: select all processes on a terminal, including those of other users
  • x: select processes without controlling ttys

ps -A; ps -e --- see every process on the system

ps -U root -u root -N --- see every process except those running as root 

ps -u user --- see process run by user
top --- dynamic real-time view of a running system. To quit press q, for help press h.
pstree --- shows running processes as a tree. The tree is rooted at either pid or init if pid is omitted. If a user name is specified, all process trees rooted at processes owned by that user are shown.
ps -ejH; ps axjf --- prints a process tree using ps
ps -eLf; ps axms --- get info about threads
ps -eo euser,ruser,suser,fuser,f,comm,label; ps axZ; ps -eM --- get security info
top -b -n1 > /tmp/process.log --- Save process snapshot to a file
top -b -n1 | mail -s 'Process snapshot' you@example.com --- email result
pgrep firefox --- pgrep looks through the currently running processes and lists the process IDs which matches the selection criteria to screen
pgrep -u root sshd --- list the process called sshd which is owned by root user

htop is interactive process viewer just like top, but allows to scroll the list vertically and horizontally to see all processes and their full command lines. Tasks related to processes (killing, renicing) can be done without entering their PIDs. To install htop type command:

atop is an interactive monitor to view the load on a Linux system. It shows the occupation of the most critical hardware resources (from a performance point of view) on system level, i.e. cpu, memory, disk and network. It also shows which processes are responsible for the indicated load with respect to cpu- and memory load on process level; disk- and network load is only shown per process if a kernel patch has been installed.

No comments:

Post a Comment