歡迎您光臨本站 註冊首頁

系統初始化

←手機掃碼閱讀     火星人 @ 2014-03-08 , reply:0

linux 系統初始化

使用方法: source sys-init

$ cat sys-init

20111115

  1. #關閉不需要的服務
  2. chkconfig atd off
  3. chkconfig cups off
  4. chkconfig bluetooth off
  5. chkconfig hidd off
  6. chkconfig ip6tables off
  7. chkconfig auditd off
  8. chkconfig autofs off
  9. chkconfig avahi-daemon off
  10. chkconfig avahi-dnsconfd off
  11. chkconfig cpuspeed off
  12. chkconfig isdn off
  13. chkconfig nscd off
  14. chkconfig pcscd off
  15. chkconfig yum-updatesd off
  16. chkconfig acpid off
  17. chkconfig autofs off
  18. chkconfig firstboot off
  19. chkconfig mcstrans off
  20. chkconfig rpcgssd off
  21. chkconfig rpcidmapd off
  22. chkconfig setroubleshoot off
  23. chkconfig xfs off
  24. chkconfig xinetd off
  25. chkconfig messagebus off
  26. chkconfig gpm off
  27. chkconfig restorecond off
  28. chkconfig haldaemon off
  29. chkconfig sysstat off
  30. chkconfig readahead_early off
  31. chkconfig anacron off
  32. chkconfig iscsid off
  33. chkconfig iscsi off
  34. chkconfig lm_sensors off
  35. chkconfig mdmonitor off
  36. chkconfig ntpd off
  37. chkconfig smb off
  38. chkconfig rawdevices off
  39. chkconfig iptables off
  40. chkconfig lvm2-monitor off
  41. chkconfig netfs off
  42. #打開需要的服務
  43. chkconfig crond on
  44. chkconfig irqbalance on
  45. chkconfig kudzu on
  46. chkconfig microcode_ctl on
  47. chkconfig messagebus on
  48. chkconfig network on
  49. chkconfig nfs on
  50. chkconfig nfslock on
  51. chkconfig portmap on
  52. chkconfig sshd on
  53. chkconfig syslog on
  54. chkconfig --list | grep '3:on'
  55. #保留兩個tty
  56. sed -ir '48,51 s/^/#/' /etc/inittab && init q
  57. #關閉selinux
  58. sed -ir 's/SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
  59. #設定最大文件句柄數量
  60. echo -e "#ulimit \nulimit -SHn 65535" >> /etc/rc.local
  61. #同步時間
  62. echo -e "#ntpdate \nntpdate 192.168.57.71" >> /etc/rc.local
  63. #tcp/ip 優化
  64. 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
  65. #.vimrc 文件
  66. echo -e 'set nobackup
  67. set number
  68. set cindent
  69. set autoindent
  70. set shiftwidth=2
  71. set tabstop=2
  72. set softtabstop=2
  73. set expandtab
  74. set ruler
  75. syntax on
  76. ' > ~/.vimrc
  77. #.bash_profile
  78. cat >~/.bash_profile <<EOF
  79. # .bash_profile
  80. # Get the aliases and functions
  81. if [ -f ~/.bashrc ]; then
  82. . ~/.bashrc
  83. fi
  84. # User specific environment and startup programs
  85. PATH=$PATH:$HOME/bin
  86. export PATH
  87. #after add
  88. ip=$(/sbin/ifconfig eth1 | grep Bcast | sed -e 's/^.* addr:\(.*\) Bcast.*$/\1/')
  89. if [ $ip ];then
  90. PS1="\[\e[32;1m\]$ip\[\e[0m\][\W]\$ "
  91. else
  92. PS1="\[\e[32;1m\]`/sbin/ifconfig eth1 | grep Bcast | sed -e 's/^.* addr:\(.*\) Bcast.*$/\1/'`\[\e[0m\][\W]\$ "
  93. fi
  94. export PATH
  95. export PS1
  96. ##export HISTIGNORE="&:history:ls:ls *:ps:ps -A:df:df *:du:du *:[bf]g:exit"
  97. #unset USERNAME
  98. echo "[LOAD]";cat /proc/loadavg;echo "[DISK]";df -Th
  99. locale | sed -r 's/zh_CN/en_US/g' > .lang
  100. source ~/.lang
  101. export HISTTIMEFORMAT="%F %T "
  102. EOF


結束

適用於批量部署linux 操作系統!


[火星人 ] 系統初始化已經有336次圍觀

http://coctec.com/docs/linux/show-post-45966.html