This shell script is primarily used to initialize the new Linux server system, including shutting down the IPV6 module, turning off the SELinux, allowing Vim to display colors, setting system language encoding, optimizing system services, kernel parameter optimization, and so on
This shell script is primarily used for initialization of newly installed Linux server systems, including:
Turn off the IPV6 module
Close SELinux
Let vim display color
Set System language encoding
Optimizing System Services
Kernel parameter optimization and so on.
Can be modified according to their actual situation, can be used in production environment. The original author is Netseek, I made a partial modification.
Copy Code code as follows:
#!/bin/sh
# desc:lsm03624 Modified by www.webnginx.com
#-------------------cut begin-------------------------------------------
#welcome
Cat << EOF
+--------------------------------------------------------------+
| = = = Welcome to Centos System init = = |
+--------------http://www.linuxtone.org------------------------+
+----------------------Author:netseek--------------------------+
EOF
#disable IPv6
Cat << EOF
+--------------------------------------------------------------+
| = = = Welcome to Disable IPV6 = = = |
+--------------------------------------------------------------+
EOF
echo "Alias net-pf-10 off" >>/etc/modprobe.conf
echo "Alias IPv6 off" >>/etc/modprobe.conf
/sbin/chkconfig--level ip6tables off
echo "IPv6 is disabled!"
#disable SELinux
sed-i '/selinux/s/enforcing/disabled/'/etc/selinux/config
echo "SELinux is disabled,you must reboot!"
#vim
sed-i "8 s/^/alias vi= ' vim '/"/ROOT/.BASHRC
echo ' syntax on ' >/ROOT/.VIMRC
#zh_cn
sed-i-E ' s/^lang=.*/lang= ' ZH_CN. UTF-8 "/'/etc/sysconfig/i18n
# Configure file Max to 52100
echo "* Soft nofile 52100
* Hard Nofile 52100 ">>/etc/security/limits.conf
#tunoff Services
#--------------------------------------------------------------------------------
Cat << EOF
+--------------------------------------------------------------+
| = = = Welcome to tunoff services = = |
+--------------------------------------------------------------+
EOF
#---------------------------------------------------------------------------------
for I in ' ls/etc/rc3.d/s* '
do
cursrv= ' echo $i |cut-c 15-'
Echo $CURSRV
Case $CURSRV in
Cpuspeed | Crond | Irqbalance | Microcode_ctl | mysqld | Network | Nginx | PHP-FPM | SendMail | sshd | syslog)
#这个启动的系统服务根据具体的应用情况设置, where network, sshd, and syslog are three system services that must be started!
echo "Base services, skip!"
*)
echo "Change $CURSRV to Off"
chkconfig--level 235 $CURSRV off
Service $CURSRV Stop
Esac
done
rm-rf/etc/sysctl.conf
echo "Net.ipv4.ip_forward = 0
Net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
KERNEL.SYSRQ = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
KERNEL.MSGMNB = 65536
Kernel.msgmax = 65536
Kernel.shmmax = 68719476736
Kernel.shmall = 134217728
Net.ipv4.ip_local_port_range = 1024 65536
Net.core.rmem_max = 16777216
Net.core.wmem_max = 16777216
Net.ipv4.tcp_rmem = 4096 87380 16777216
Net.ipv4.tcp_wmem = 4096 65536 16777216
net.ipv4.tcp_fin_timeout = 3
net.ipv4.tcp_tw_recycle = 1
Net.core.netdev_max_backlog = 30000
Net.ipv4.tcp_no_metrics_save = 1
net.core.somaxconn = 262144
net.ipv4.tcp_syncookies = 0
Net.ipv4.tcp_max_orphans = 262144
Net.ipv4.tcp_max_syn_backlog = 262144
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2
vm.swappiness = 6 ">>/etc/sysctl.conf
echo "optimizited kernel Configure was done!"