Command Line Tools to Monitoring & Managing Linux Performance/Process

originalA process is a running instance of a launched, executable program. So being a System Engineer it is not easy to monitor Linux server/system performances and keep them up and running, here in this post i will cover mostly used command line to monitoring that might be useful for those who are taking care of Linux servers/systems as Linux Administrator.

Real- time Process Monitoring by ‘ top ‘:

The ‘ top ‘ command line, top program show a dynamic view of system processes and displaying a summary or  it is used to dipslay all the running and active real-time processes in ordered list. It display CPU usage, Memory usage, Swap Memory, Cache Size, Buffer Size, Process PID, User, Commands and much more. It also shows high memory and cpu utilization of a running processess.  And ‘ top ‘ command continuously refreshes at a configurable interval and provides above summary in a column view. The top command is more useful for system administrator to monitor and take correct action when required.

[gaurav@linuxpoint ~] $  top


To quit press q, for help press h.

  1. To Save Process Snapshot to a file by type the following command:

[gaurav@linuxpoint ~]$ top -b -n1 > /tmp/process.log

Or you can email result to yourself:
[gaurav@linuxpoint ~] $  top -b -n1 | mail -s 'Process snapshot'

Linux Process Monitoring by ‘ htop ‘ :

“htop” is a third party tool and doesn’t included in Linux systems, you need to install it by using YUM package manager tool for Redhat and for Ubuntu need to install it by apt-get. It is much similar to Linux top command but it has some advanced features like user friendly interface to manage process, shortcut keys etc.

It 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.

[gaurav@linuxpoint ~] $  sudo   apt-get    install    htop

[gaurav@linuxpoint ~] $ sudo  yum  install  htop

[gaurav@linuxpoint ~] $ htop


Linux Process Monitoring BY ‘ atop ‘:

atop ‘ command or program 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.

[gaurav@linuxpoint ~] $ atop

Virtual Memory Statistics – VmStat command :

Linux VmStat command used to display statistics of  system processes, I/O blocks, interrupts, CPU activity, virtual memory, kernerl threads, disksetc. By default vmstat command is not available under Linux systems you need to install a package called sysstat that includes a vmstat program.

[gaurav@linuxpoint ~] $ vmstat

List Open Files – lsof

‘ lsof ‘ command used in many Linux/Unix like system that is used to display list of all the open files and the processes. The open files included are disk files, network sockets, pipes, devices and processes.

One of the main reason for using this command is when a disk cannot be unmounted and displays the error that files are being used or opened. With this command you can easily identify which files are in use.

[gaurav@linuxpoint ~] $ lsof

To Monitor Linux Disk I/O – iotop command

‘ iotop ‘ command is also much similar to top command and htop program, but it has accounting function to monitor and display real time Disk I/O and processes. This tool is much useful for finding the exact process and high used disk read/writes of the processes.

[gaurav@linuxpoint ~] $ iotof

Show All Running Processes in Linux – ‘ ps’ command:

We need to use the ps command. It provide information about the currently running processes, including their process identification numbers (PIDs).

The ‘ ps ‘ command gives a snapshot of the current processes. If you want a repetitive update of this status, use top, atop, and/or htop command as described above.

  1. top command : Display and update sorted information about processes.
  2. atop : Advanced System & Process Monitor.
  3. htop : Interactive process viewer.

Type the following ps command to display all running process:
[gaurav@linuxpoint ~] $  ps aux | less

  • -A: select all processes
  • a: select all processes on a terminal, including those of other users
  • x: select processes without controlling ttys
  1.  To see every process on the system

[gaurav@linuxpoint ~] $ ps    -A

[gaurav@linuxpoint~]$ ps -e

2. To see every process except those running as gaurav

[gaurav@linuxpoint ~]$ ps -U gaurav -u gaurav -N

3. To see process run by user abc

[gaurav@linuxpoint ~]$ ps -u abc

display a tree of processes- ‘pstree’

‘ 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.

[gaurav@linuxpoint ~]$ pstree

  1. To Print a process tree using  ‘ps’

[gaurav@linuxpoint ~]$ ps -ejH
[gaurav@linuxpoint ~]$ ps axjf

2. To Get info about threads by the  following command:
[gaurav@linuxpoint ~]$ ps -eLf

[gaurav@linuxpoint ~]$ ps axms

Lookup process by pgrep:

pgrep ‘ command, looks through the currently running processes and lists the process IDs which matches the selection criteria to screen. For example display httpd process id:
[gaurav@linuxpoint ~]$ pgrep httpd
Sample outputs:


Following command will list the process called sshd which is owned by a user called root:
[gaurav@linuxpoint ~]$ pgrep -u root sshd

And there are many othes tools available for monitoring the system performance  like

1. Linux Process and Services Monitoring by Monit

Monit is a free open source and web based process supervision utility that automatically monitors and managers system processes, programs, files, directories, permissions, checksums and filesystems.

It also monitors services like Apache, MySQL, Mail, FTP, ProFTP, Nginx, SSH etc. The system status can be viewed from the command line or using it own web interface.

2. System and Network Monitoring by Monitorix

Monitorix is a free lightweight utility that is designed to run and monitor system and network resources as many as possible in Linux/Unix servers. It has a built in HTTP web server that regularly collects system and network information and display them in graphs. It Monitors system load average and usage, memory allocation, disk driver health, system services, network ports, mail statistics (Sendmail, Postfix, Dovecot, etc), MySQL statistics and many more. It designed to monitor overall system performance and helps in detecting failures, bottlenecks, abnormal activities etc.

3.Nagios and zabbix – Network/Server Monitoring
4. Monitor Linux Performance  by ‘Nmon’:

Nmon (stands for Nigel’s performance Monitor) tool, which is used to monitor all Linux resources such as CPU, Memory, Disk Usage, Network, Top processes, NFS, Kernel and much more. This tool comes in two modes: Online Mode and Capture Mode.

The Online Mode, is used for real-time monitoring and

Capture Mode, is used to store the output in CSV format for later processing.

So, here above the most basic commands and tools for monitoring performence are covered and it is not end of commands and tools there are more command and tools . I hope you all liked it and enjoyed.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s