linux 系統初始化
使用方法: source sys-init
$ cat sys-init
20111115
- #關閉不需要的服務
- 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 lvm2-monitor off
- chkconfig netfs off
- #打開需要的服務
- chkconfig crond on
- chkconfig irqbalance on
- chkconfig kudzu on
- chkconfig microcode_ctl on
- chkconfig messagebus on
- chkconfig network on
- chkconfig nfs on
- chkconfig nfslock on
- chkconfig portmap on
- chkconfig sshd on
- chkconfig syslog on
- chkconfig --list | grep '3:on'
- #保留兩個tty
- sed -ir '48,51 s/^/#/' /etc/inittab && init q
- #關閉selinux
- sed -ir 's/SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
- #設定最大文件句柄數量
- echo -e "#ulimit \nulimit -SHn 65535" >> /etc/rc.local
- #同步時間
- echo -e "#ntpdate \nntpdate 192.168.57.71" >> /etc/rc.local
- #tcp/ip 優化
- echo -e 'net.ipv4.tcp_tw_reuse = 1 \nnet.ipv4.tcp_tw_recycle = 1 \nnet.ipv4.ip_local_port_range = 1024 65000 \nnet.ipv4.tcp_syncookies = 1' >> /etc/sysctl.conf && sysctl -p
- #.vimrc 文件
- echo -e 'set nobackup
- set number
- set cindent
- set autoindent
- set shiftwidth=2
- set tabstop=2
- set softtabstop=2
- set expandtab
- set ruler
- syntax on
- ' > ~/.vimrc
- #.bash_profile
- cat >~/.bash_profile <<EOF
- # .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
- #after add
- ip=$(/sbin/ifconfig eth1 | grep Bcast | sed -e 's/^.* addr:\(.*\) Bcast.*$/\1/')
- if [ $ip ];then
- PS1="\[\e[32;1m\]$ip\[\e[0m\][\W]\$ "
- else
- PS1="\[\e[32;1m\]`/sbin/ifconfig eth1 | grep Bcast | sed -e 's/^.* addr:\(.*\) Bcast.*$/\1/'`\[\e[0m\][\W]\$ "
- fi
- export PATH
- 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
- export HISTTIMEFORMAT="%F %T "
- EOF
結束
適用於批量部署linux 操作系統!
[火星人 ] 系統初始化已經有336次圍觀