In this article, We are going to see how we can check linux systems health with 10 powerful commands and shell script.
Administration, continuous monitoring performance of servers is the primary duty of any system administrator. You can do all the task on linux machines but, if don’t know basic and advanced commands you may not understand what happening on the server and how to troubleshoot in a real time environment. So, this article let you know 10 powerful commands and using this commands you can check your linux servers performance and resolved issue which you may faced.
- Any linux machine
- SSH Access with sudo privileges
Now, lets check linux systems health with 10 powerful commands,
This is a basic command and it comes pre installed with almost every linux distributions. Using Top command you can get the information about running process ID (PID) users, CPU usage, time, memory and swap usage etc. Check the below image for more information’s.
Htop is a similar tool as “Top” and it is also used to monitor your systems process on linux machines. Using Htop you can do customization, kill running processes it has interactive overview. By default its not comes with linux distributions you have to install it on you machine. Htop is better than Top because it has more interactive overview and easy to perform required task. your system should have Epel repository installed and enabled, to installed Htop So, run the following commands on your respective distributions to install and enable it for your system architecture (32bit or 64bit)
For RHEL/CentOS 5 (32 bit OS)
# wget http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm # rpm -ihv epel-release-5-4.noarch.rpm
For RHEL/CentOS 6 (32 bit OS)
# wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm # rpm -ihv epel-release-6-8.noarch.rpm
For RHEL/CentOS and Fedora (64 bit OS)
===================For RHEL/CentOS 5 =================================== # wget http://download.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm # rpm -ihv epel-release-5-4.noarch.rpm
===================For RHEL/CentOS 6 =================================== # wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm # rpm -ihv epel-release-6-8.noarch.rpm
===================For RHEL/CentOS 7 =================================== # yum install epel-release
==================For RHEL/CentOS 8 ==================================== # yum install epel-release [CentOS 8] # dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm [RHEL 8]
Once the EPEL repository installed on your machine you can use below command to install Htop on RHEL/CentOS distributions
#yum install htop -y
For Debian and Ubuntu distributions you can use below command to install Htop
# sudo apt-get install htop
“nethogs” is the tools which gives you details about opened ports and IP address connections over the internet. This command also provide bandwidth consumption information for each opened connections. you can use below command to install this command,
#yum install nethogs
“Free” tool come preinstalled with all linux distributions. Using this tool you can check memory usage for your running linux machines, even you can check cached and buffer memory as well. You can use different switches like -m, -g -h to check all the details.
“lostat” command can be used to check CPU and disk I/O state
You can use below command to install “sar” This command is similar in some case with “lostat” This command can use to check disk I/O writes with other multipal parameters for last half and hours.
This “mytop” tool can used to monitor mysql performance, this command opened and keep refreshing connection for mysql and monitor database process list, you can use below command;
#mytop –u root –p XXX –d mysql
This “atop” command can use to check server loads, this command is combination of “top” and “htop” this command has an extra feature for daily level logging. This command shows the processes which reached to their threshold limit of the load.
“lsof” command used to check opened back ends files and process. You can use this command for any partition or any respected directories. For example you can use below command;
# lsof /var
This “vmstat” command used to check and monitor virtual memory status. You can monitor VM for every intervals using below commands, 5 is the seconds here.