Linux CentOS7 CentOS6 Base Package and Environment

Linux Base Package

echo "PS1='\033[1;33m\t \033[1;33m[\u@\H] \033[1;35m\w\033[0;0m\n#'" >> /root/.bashrc

. .bashrc

rm -f anaconda-ks.cfg

export http_proxy=http://111.223.53.1:8080
export https_proxy=http://111.223.53.1:38080


sed -i '/keepcache=0/c keepcache=1' /etc/yum.conf


yum -y install epel-release


# centos 6
yum -y install wget
wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
sudo rpm -Uvh epel-release-*.rpm


# For Physical Server
yum -y install libvirt-client htop dmidecode wget screen net-tools snmpd net-snmp-utils perl perl-libwww-perl vim sysstat iftop zip unzip iptstate yum-utils nc lsof net-snmp ntp bash-completion curl lsof bridge-utils bind-utils nfs-utils telnet bzip2 pciutils git perl-core ipmi OpenIPMI deltarpm


# for vmware
yum -y install open-vm-tools dmidecode htop perl-libwww-perl wget screen net-tools snmpd net-snmp-utils perl vim sysstat iftop zip unzip iptstate yum-utils nc lsof net-snmp ntp bash-completion curl lsof bridge-utils bind-utils nfs-utils telnet bzip2 pciutils git perl-core ipmi deltarpm

# For KVM Server 
yum -y install libvirt-client htop dmidecode wget screen net-tools snmpd net-snmp-utils perl perl-libwww-perl vim sysstat iftop zip unzip iptstate yum-utils nc lsof net-snmp ntp bash-completion curl lsof bridge-utils bind-utils nfs-utils telnet bzip2 pciutils git perl-core ipmi qemu-guest-agent deltarpm 

systemctl stop NetworkManager 
systemctl disable NetworkManager
yum -y erase NetworkManager
systemctl stop postfix
yum -y remove postfix
systemctl stop chronyd
yum -y remove chrony
yum -y remove firewalld* 

# sshd config
sed -i '/Defaults    requiretty/c #Defaults    requiretty' /etc/sudoers
sed -i '/#UseDNS yes/c UseDNS no' /etc/ssh/sshd_config
systemctl restart sshd

# set NTP
sed -i '/server 0.centos.pool.ntp.org iburst/c server 202.170.119.19' /etc/ntp.conf
sed -i '/server 1.centos.pool.ntp.org iburst/c server 202.170.119.9' /etc/ntp.conf
sed -i '/server 2.centos.pool.ntp.org iburst/c server 103.246.188.99' /etc/ntp.conf
sed -i '/server 3.centos.pool.ntp.org iburst/c #' /etc/ntp.conf
systemctl enable ntpd
systemctl restart ntpd

# set SELINUX=permissive
setenforce 0
sed -i '/SELINUX=enforcing/c SELINUX=disabled' /etc/sysconfig/selinux 
sed -i '/SELINUX=enforcing/c SELINUX=disabled' /etc/selinux/config

# Update to Lastest version
yum -y update

echo "export EDITOR=\"vim\"" >> .bashrc
echo "alias vi='vim'"  >> .bashrc

## Set snmpd
SNMPNAME=SNMProm
echo "com2sec mynetwork 0.0.0.0/0 $SNMPNAME" > /etc/snmp/snmpd.conf
echo "group MyROGroup any mynetwork" >> /etc/snmp/snmpd.conf
echo "view all included .1 80" >> /etc/snmp/snmpd.conf
echo "access MyROGroup \"\" any noauth 0 all none none" >> /etc/snmp/snmpd.conf
echo "syslocation Thailand" >> /etc/snmp/snmpd.conf
echo "syscontact IT <[email protected]>" >> /etc/snmp/snmpd.conf
echo "" >> /etc/snmp/snmpd.conf
systemctl enable snmpd
systemctl start snmpd

# Set Hostname
HOSTNAMETODO="HOSTNAME"
hostnamectl set-hostname $HOSTNAMETODO --static

# Restart to Lastest
reboot

# Remove unuse kernel
yum -y remove kernel