How to use linux shell 2
Subtitle: Server check
Version / revision: V1.0 / R 0.0.
For Nethserver all version.
Skill: Novice / Beginner
Date of presentation: Released on 2016-06-25
Target
This howto is intended for beginners.
From linux shell you can make various checks on a server. There are simple commands (but very powerful) that allow an efficient analysis of a server to test problems or performance.
I will list some of the many existing commands (for each one would need a howto…).
It would be interesting to integrate it with the ideas of all.
Premise:
For many of the following commands must be enabled rpmforge and EPEL repository (disable it at the end!)
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm rpm -Uvh epel-release-6-8.noarch.rpm wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm rpm -Uvh rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
Process Control:
top
Install:
No need to install
Command:
top
Standard program to check processor activity in real time. Lists the use of ram and cpu for every user processes.
htop
Installation:
yum install htop
Command:
htop
As top but more user friendly. Permit filter by process, user…
ps
Installation:
No need to install
Command:
ps aux ps -fp $(pgrep -d, http)
It lists the active processes. With the appropriate parameters it allows to monitor specific processes.
kill, killall
Installation:
No need to install
Command:
kill -9 1234 killall -9 clamd
This command is used to terminate one or more processes.
Kill requires one or more pid (separated by space); killall terminates the process by name.
Network Control:
iftop
Installation:
yum install iftop
Command:
iftop
Very intuitive utility to verify the use of server's bandwidth. It identifies source and destination IP.
tcptrack
Installation:
yum install tcptrack
Command:
tcptrack -i eth0
Captures network packets and determines the use of bandwidth for each IP / service.
iptraf
Installation:
yum install iptraf
Command:
iptraf
Network traffic tool. Displays for each interface tcp, udp, icmp and non IP traffic identifying source and destination.
tcpdump
Installation:
No need to install
Command:
tcpdump -i eth0 tcpdump -i eth0 > file.txt
netstat
Installation:
No need to install
Command:
netstat -r netstat -lnp netstat -a |grep ssh
Very useful network tool. Depending on the switch, you can check the settings or analyze the listening processes.
trafshow
Installation:
yum install trafshow
Command:
trafshow -i eth0 trafshow -n -i eth0 tcp
File control:
lsof
Installation:
No need to install
Command:
lsof lsof |grep "stringa" lsof +D /var/log/
Command line utility used to list information about the files that are opened.
iotop
Installation:
yum install iotop
Command:
iotop iotop -o
Program to monitor in real time the disk activity. It identify the processes that cause it.
With -o parameter displays only the processes that generate traffic, hiding inactive.