centos模板機制作前修改配置
1.關閉selinux
sed -i ‘s#SELINUX=enforcing#SELINUX=disabled#g‘ /etc/selinux/config
setenforce 0 臨時生效,想要長期生效,重啟系統
getenforce 查看selinux狀態
2.關閉防火墻
/etc/init.d/iptables stop
/etc/init.d/iptables stop 要關閉至少2次
chkconfig iptables off
3.精簡開機自啟動服務
chkconfig|egrep -v "crond|sshd|network|rsyslog|sysstat"|awk ‘{print "chkconfig",$1,"off"}‘|bash
chkconfig --list|grep 3:on
4.提權oldboy可以sudo
useradd oldboy
\cp /etc/sudoers /etc/sudoers.ori
echo "oldboy ALL=(ALL) NOPASSWD:ALL">>/etc/sudoers
tail -l /etc/sudoers
visudo -c
5.中文字符集
先查看
[[email protected] ~]# cat /etc/sysconfig/i18n
LANG="en_US.UTF-8"
SYSFONT="latarcyrheb-sun16"
再備份
[[email protected]
再修改
[[email protected] ~]# echo ‘LANG="zh_CN.UTF-8"‘>/etc/sysconfig/i18n
[[email protected] ~]# source /etc/sysconfig/i18n
#使上文修改生效
[[email protected] ~]# echo $LANG
查看當前字符集狀態
6.時間同步
[[email protected] ~]# echo ‘#time sync by oldboy at 2010-2-1‘>>/var/spool/cron/root
[[email protected] ~]# crontab -l
#time sync by oldboy at 2010-2-1
*/5 * * * * /usr/sbin/ntpdate time.nist.gov >/dev/null 2>&1
7.命令行安全
[[email protected] ~]# #time sync by oldboy at 2010-2-1
[[email protected] ~]# echo ‘export TMOUT=300‘ >>/etc/profile
[[email protected] ~]# echo ‘export HISTSIZE=5‘ >>/etc/profile
[[email protected] ~]# echo ‘export HISTFILESIZE=5‘ >>/etc/profile
[[email protected] ~]# tail -3 /etc/profile
[[email protected] ~]# . /etc/profile
8.加大文件描述
[[email protected] ~]# echo ‘* - nofile 65535‘ >>/etc/security/limits.conf
[[email protected] ~]# tail -1 /etc/security/limits.conf
* - nofile 65535
9.內核優化
本文出自 “sandshell” 博客,請務必保留此出處http://sandshell.blog.51cto.com/9055959/1950291
centos模板機制作前修改配置