Friday, September 12, 2014

Toolbox for Linux admin !

A. Network / Diagnostic / Monitoring tools:

1. ifstat - Report InterFace STATistics

2. vmstat - Report virtual memory statistics

3. iostat  -  Report Central Processing Unit (CPU) statistics and input/output statistics for devices,
                     partitions and network filesystems (NFS)

4. Dstat -    A versatile replacement for vmstat, iostat and ifstat. Dstat overcomes some of the
                      limitations and adds some extra features.

5. iptraf - Interactive IP LAN Monitor

6. top - display Linux tasks

7. sar - Collect, report, or save system activity information.

8. mpstat - Report processors related statistics.

9. pmap - report memory map of a process

10. ss - Utility to investigate sockets

eg.
# ss -l
Recv-Q Send-Q                     Local Address:Port                         Peer Address:Port
0      128                                   :::ssh                                    :::*    
0      128                                    *:ssh                                     *:*    
0      5                              127.0.0.1:42551                                   *:*    

11. netstat - Print network connections, routing tables, interface statistics, masquerade con‐nections,
                    and multicast memberships

12. nmap - Network exploration tool and security / port scanner

13. nethogs - Net top tool grouping bandwidth per process

14. tcpdump - dump traffic on a network

eg.
tcpdump -i eth0 'udp port 53'

This shows all packets going in and out of the machine for UDP port 53

15. sosreport - Generate debugging information for system

16. iftop - display bandwidth usage on an interface by host


B. Utilities:

1. AIDE - Advanced Intrusion Detection Environment. A host-based intrusion detection system
                          (HIDS) for checking the integrity of files. It does this by creating a baseline database
                          of files on an initial run, and then checks this database against the system on
                          subsequent runs.

2. DenyHosts - is a log-based intrusion prevention security tool for SSH servers.

3. Fail2ban - Fail2ban scans log files (e.g. /var/log/apache/error_log) and bans IPs that show the
                        malicious signs -- too many password failures, seeking for exploits, etc

4. Monit - utility for monitoring services on a Unix system

5.

Installing Java-7 and Apache Tomcat/8.0.12 on CentOS-6.5


I. JAVA:

1. Search JDK in the yum repositories;

# yum search java | grep -i --color JDK
ldapjdk-javadoc.x86_64 : Javadoc for ldapjdk
icedtea-web.x86_64 : Additional Java components for OpenJDK - Java browser
java-1.6.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.6.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.6.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.6.0-openjdk-javadoc.x86_64 : OpenJDK API Documentation
java-1.6.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.7.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.7.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.7.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.7.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.7.0-openjdk-src.x86_64 : OpenJDK Source Bundle
ldapjdk.x86_64 : The Mozilla LDAP Java SDK

2. Once found, install the required version (if the search does yield any result then please download
         and install manually).

# yum install java-1.7.0-openjdk java-1.7.0-openjdk-devel

3. Check if there are already installed versions of Java;

# alternatives --config java

There is 1 program that provides 'java'.

Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java

Enter to keep the current selection[+], or type selection number:

4. Set JAVA_HOME varaiable and include Java binaries in the system PATH;

# vi /etc/profile

## Set JAVA_HOME
JAVA_HOME="/usr/lib/jvm/jre-1.7.0-openjdk.x86_64"
export JAVA_HOME

## Set JAVA Path
PATH=$PATH:/usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin

5. Execute the file so that the new changes are reflected on the system;
# source /etc/profile

6. Test Java:
A. # echo $JAVA_HOME
/usr/lib/jvm/jre-1.7.0-openjdk.x86_64

B. # cat > HelloWorld.java
  public class HelloWorld {
public static void main(String[] args) {
         System.out.println("Hello, World! ");
    }
  }

# javac HelloWorld.java
# java HelloWorld
Hello, World!

II. Apache Tomcat

1. Download Apache Tomcat/8.0.12:
# wget http://apache.mirrors.pair.com/tomcat/tomcat-8/v8.0.12/bin/apache-tomcat-8.0.12.tar.gz

2. Extract:
# tar -xvzf apache-tomcat-8.0.12.tar.gz

3. I moved the extracted directory under /usr/local;
# mv apache-tomcat-8.0.12 /usr/local/

4. # /usr/local/apache-tomcat-8.0.12/bin/startup.sh
Using CATALINA_BASE:   /usr/local/apache-tomcat-8.0.12
Using CATALINA_HOME:   /usr/local/apache-tomcat-8.0.12
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-8.0.12/temp
Using JRE_HOME:        /usr/lib/jvm/jre-1.7.0-openjdk.x86_64
Using CLASSPATH:       /usr/local/apache-tomcat-8.0.12/bin/bootstrap.jar:/usr/local/apache-
        tomcat-8.0.12/bin/tomcat-juli.jar
Tomcat started.