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* '
Todo
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!"