LINUX System Initialization Scripts

Source: Internet
Author: User

#!/bin/bash
##### #the System First start configuretion # # #for Install
# # # #copy right by donglei##############
#1, configuring Sysctl
Mv/etc/sysctl.conf/etc/sysctl.bak
echo "########################### #the new config for Sysctl ###########
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 = 4294967296
Kern.maxfiles = 65536
Kern.maxfilesperproc = 32768
Net.core.rmem_default = 262144
Net.core.wmem_default = 262144
Net.core.rmem_max = 262144
Net.core.wmem_max = 262144
Net.inet.udp.checksum = 1
Net.inet.tcp.syncookies = 1
Net.ipv4.tcp_synack_retries = 2
Net.ipv4.tcp_syn_retries = 2
Net.ipv4.tcp_keepalive_time = 30
Net.ipv4.tcp_keepalive_probes = 2
NET.IPV4.TCP_KEEPALIVE_INTVL = 2
Net.ipv4.tcp_fin_timeout = 30
Net.ipv4.tcp_tw_reuse = 1
Kernel.sem = 250 32000 100 128
Fs.file-max = 65536
Net.ipv4.ip_local_port_range = 65000 ">>/etc/sysctl.conf
chmod 644/etc/sysctl.conf
#2, configuring IPv6
echo "######### #ipv6-disabled###########
Alias net-pf-10 off
Alias IPv6 off ">>/etc/modprobe.d/dist.conf
echo "############# #ipv6-disabled#########
Networking_ipv6=no ">>/etc/sysconfig/network
/sbin/chkconfig Ip6tables off
#3, configuring the system clock
echo "############# #system_clock ###########
* * * * * root ntpdate 172.17.1.150; Hwclock--SYSTOHC ">>/etc/crontab
#4, configure the bash environment, each command line displays the current location and time, currently only for root settings
echo "Export ps1= ' \033[1;33m\h \033[1;34m[\w] \033[1;35m\d{%d%t}\n\[\033[1;36m\]\[email protected]/\l \[\033[00m\]\$ ' >>/ROOT/.BASHRC
#5, configure system service startup items
For i in ' ls/etc/rc3.d/s* '
Do
Servi= ' echo $i |cut-c 15-'
Case $servi in
Cpuspeed | Crond | Irqbalance | Microcode_ctl | SendMail
;;
*)
echo "Change $servi to Off" >>./log.log
Chkconfig $servi off
Service $servi Stop
;;
Esac
Done
#6, configuring the system default language environment
Mv/etc/sysconfig/i18n/etc/sysconfig/i18n.bak
echo "######## #set new language by admin#######
Lang= "ZH_CN. UTF-8 "
Supported= "ZH_CN. Utf-8:zh_cn:zh:en_us. Utf-8:en_us:en "
Sysfont= "Latarcyrheb-sun16" ">/etc/sysconfig/i18n
chmod 644/etc/sysconfig/i18n
#7, configuring SELinux
Sed-i-E ' s/^selinux=.*/lang= "selinux=disabled/'-e ' s/^selinuxtype=.*/selinuxtype=disabled/'/etc/sysconfig/ SELinux
#8, close iptables
Service Iptables Stop
Chkconfig iptables off
#9, configuration root user cannot log in directly to the system
Mv/etc/ssh/sshd_config/etc/ssh/sshd_config.bak
Grep-ev ' ^$|^# '/etc/ssh/sshd_config.bak >/etc/ssh/sshd_config
chmod 600/etc/ssh/sshd_config
SED/PERMITROOTLOGIN/D/etc/ssh/sshd_config
SED/CLIENTALIVECOUNTMAX/D/etc/ssh/sshd_config
echo "##### #ssh security config#######
Permitrootlogin No
Clientalivecountmax ">>/etc/ssh/sshd_config
Service sshd Restart

LINUX System Initialization Scripts

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.