Tag:linux initialization shell system
#!/bin/bash# author:juchangfei# blog:http://changfei.blog.51cto.com if [ ' WhoAmI ' != "root" ];thenecho "please use root!" Exit 1fi#common installation packageyum -y install sysstat iptraf curl curl-devel ntp wget lsof strace lrzsz cmake setuptool#set runlevel to 3sed -i ' s/id:.*$/id:3:initdefault:/g ' /etc/inittab#set ulimit to 102400checklimits= ' grep ' * - nofile ' /etc/security/limits.conf ' if [ ' $ Checklimits " == " ] ; thenecho ' * - nofile 102400 ' >> /etc/security/limits.conffi#disable selinuxsed -i ' s/selinux=enforcing/selinux=disabled/g ' /etc/selinux/config#set time zoneecho ' zone= "Asia/shanghai" ' > /etc/ Sysconfig/clock#set ntpdate serverntptmp= ' Crontab -l |grep ' ntpdate ' if [ "$ntptmp" == " ];thenecho " 30 00 * * * /usr/sbin/ntpdate ntp.server.com " >> /var/spool/cron/rootfi#30 minutes of no activity, automatically exitecho "TMOUT=1800" >> / etc/profile#disable ipv6echo "Alias net-pf-10 off" >> /etc/ modprobe.confecho "Alias ipv6 off" >> /etc/modprobe.conf/sbin/chkconfig -- level 35 ip6tables offsed -i "S/networking_ipv6=yes/networking_ipv6=no/g" /etc/ sysconfig/network#turnoff servicefor i in ' ls /etc/rc3.d/s* ' do serviename= ' echo $i |cut -c 15-' echo $serviename case $serviename in crond | irqbalance | microcode_ctl | network | random | sshd | syslog | auditd | cpuspeed | xinetd | mon | partmon | messagebus| udev-post | sshd | rsyslog | syslog ) echo "skip this service! " ;; *) echo "$serviename off" chkconfig --level 235 $serviename off service $serviename stop ;; esacdone#set by the history view history command displays only 10sed -i "s/histsize=1000/histsize=10/" /etc/profile#ssh security reinforce# Only sed -i "s/#Protocol 2,1/protocol 2/" SSH2 mode is allowed /etc/ssh/sshd_config # Specifies the maximum number of authentications allowed per connection. The default value is 6sed -i "s/#MaxAuthTries 6/maxauthtries 6/" /etc/ssh/sshd_config # Do not use DNS to resolve sed -i "s/#UseDNS yes/usedns no/" /etc/ssh/sshd_config # Null password user login is not allowed (only plaintext password method, non-certificate method). sed -i "s/#PermitEmptyPasswords no/permitemptypasswords no/" /etc/ssh/sshd_config# Enable rsa authentication. sed -i "s/#RSAAuthentication yes/rsaauthentication yes/" /etc/ssh/sshd_config# Enable public key authentication. sed -i "s/#PubkeyAuthentication yes/pubkeyauthentication yes/" /etc/ssh/sshd_ config# prohibit plaintext password login. sed -i "s/#PasswordAuthentication yes/passwordauthentication no/" /etc/ssh/sshd _config#set sysctl.confcat >> /etc/sysctl.conf <<eof#init sysctlnet.ipv4.ip_forward = 0net.ipv4.conf.default.rp_filter = 1net.ipv4.conf.default.accept_source_route = 0kernel.sysrq = 0kernel.core_uses_pid = 1net.ipv4.tcp_syncookies = 1kernel.msgmnb = 65536kernel.msgmax = 65536kernel.shmmax = 68719476736kernel.shmall = 4294967296net.ipv4.tcp_max_tw_buckets = 6000net.ipv4.tcp_sack = 1net.ipv4.tcp_window_scaling = 1net.ipv4.tcp_rmem = 4096 87380 4194304net.ipv4.tcp_wmem = 4096 16384 4194304net.core.wmem_default = 8388608net.core.rmem_default = 8388608net.core.rmem_max = 16777216net.core.wmem_max = 16777216net.core.netdev_max_backlog = 262144net.core.somaxconn = 262144net.ipv4.tcp_max_orphans = 3276800net.ipv4.tcp_max_syn_backlog = 262144net.ipv4.tcp_timestamps = 0net.ipv4.tcp_synack _retries = 1net.ipv4.tcp_syn_retries = 1net.ipv4.tcp_tw_recycle = 1net.ipv4.tcp_ Tw_reuse = 1net.ipv4.tcp_mem = 94500000 915000000 927000000net.ipv4.tcp_fin_ timeout = 1net.ipv4.tcp_keepalive_time = 1200net.ipv4.ip_local_port_range = 1024 65535eof/sbin/sysctl -p#set localetrue > /etc/sysconfig/i18ncat >>/etc /sysconfig/i18n <<eoflAng= "ZH_CN. GB18030 "Language=" ZH_CN. Gb18030:zh_cn. GB2312:ZH_CN "supported=" ZH_CN. Utf-8:zh_cn:zh:en_us. Utf-8:en_us:en "sysfont=" Lat0-sun16 "EOF
This article is from "Gan nan has" blog, please be sure to keep this source http://changfei.blog.51cto.com/4848258/1672652
Linux System initialization scripts