Linux 系統初始化腳本linux
適用於批量部署linux 操做系統!vim
#update 20130305bash
cat sys-init.shcookie
- #!/bin/bash
- #linux system initialization
- #update 20130305 by dongnan
- #
- #關閉不須要的服務
- chkconfig atd off
- chkconfig cups off
- chkconfig bluetooth off
- chkconfig hidd off
- chkconfig ip6tables off
- chkconfig auditd off
- chkconfig autofs off
- chkconfig avahi-daemon off
- chkconfig avahi-dnsconfd off
- chkconfig cpuspeed off
- chkconfig isdn off
- chkconfig nscd off
- chkconfig pcscd off
- chkconfig yum-updatesd off
- chkconfig acpid off
- chkconfig autofs off
- chkconfig firstboot off
- chkconfig mcstrans off
- chkconfig rpcgssd off
- chkconfig rpcidmapd off
- chkconfig setroubleshoot off
- chkconfig xfs off
- chkconfig xinetd off
- chkconfig messagebus off
- chkconfig gpm off
- chkconfig restorecond off
- chkconfig haldaemon off
- chkconfig sysstat off
- chkconfig readahead_early off
- chkconfig anacron off
- chkconfig iscsid off
- chkconfig iscsi off
- chkconfig lm_sensors off
- chkconfig mdmonitor off
- chkconfig ntpd off
- chkconfig smb off
- chkconfig rawdevices off
- chkconfig iptables off
- chkconfig netfs off
- chkconfig nfs off
- chkconfig nfslock off
- chkconfig portmap off
- chkconfig hplip off
- chkconfig nfs off
- chkconfig nfslock off
- chkconfig portmap off
- #打開須要的服務
- chkconfig crond on
- chkconfig irqbalance on
- chkconfig kudzu on
- chkconfig microcode_ctl on
- chkconfig messagebus on
- chkconfig network on
- chkconfig sshd on
- chkconfig syslog on
- chkconfig --list | grep '3:on'
- #關閉selinux
- sed -ir 's/SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
- #設定最大文件句柄數量
- echo -e '* soft nofile 65536
- * hard nofile 65536' >> /etc/security/limits.conf
- #同步時間
- echo -e "#ntpdate \n/usr/sbin/ntpdate time-nw.nist.gov" >> /etc/rc.local
- #tcp/ip 優化
- echo -en '#begin
- net.ipv4.tcp_tw_reuse = 1
- net.ipv4.tcp_fin_timeout = 30
- net.ipv4.ip_local_port_range = 10240 65000
- net.ipv4.tcp_max_syn_backlog = 16384
- net.ipv4.tcp_synack_retries = 3
- net.ipv4.tcp_syncookies = 1\n' >> /etc/sysctl.conf
- sysctl -p
- #.vimrc 文件
- cat > ~/.vimrc << EOF
- set nobackup
- set number
- set cindent
- set autoindent
- set shiftwidth=2
- set tabstop=2
- set softtabstop=2
- set expandtab
- set ruler
- syntax on
- EOF
- #.bash_profile
- echo -en '# .bash_profile
- # Get the aliases and functions
- if [ -f ~/.bashrc ]; then
- . ~/.bashrc
- fi
- # User specific environment and startup programs
- PATH=$PATH:$HOME/bin
- export PATH
- HISTTIMEFORMAT="$(whoami) [%Y-%m-%d %H:%M:%S] " && export HISTTIMEFORMAT
- #after add
- ip=`/sbin/ifconfig eth0 | grep Bcast | sed -e "s/^.* addr:\\(.*\\) Bcast.*$/\1/"` || ip=`/sbin/ifconfig eth1 | grep Bcast | sed -e "s/^.* addr:\\(.*\\) Bcast.*$/\1/"`
- PS1="\[\e[32;1m\]$ip\[\e[0m\][\W]\$ " && export PS1
- #export HISTIGNORE="&:history:ls:ls *:ps:ps -A:df:df *:du:du *:[bf]g:exit"
- #unset USERNAME
- echo "[LOAD]";cat /proc/loadavg;echo "[DISK]";df -Th
- locale | sed -r 's/zh_CN/en_US/g' > .lang
- source ~/.lang \n' > ~/.bash_profile
結束
更多請:
linux 系統運維 37275208
vmware 虛擬化 166682360運維