首页 > 代码库 > centos模板机制作前修改配置

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
export LANG=en
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.中文字符集
先查看
[root@oldboy ~]# cat /etc/sysconfig/i18n
LANG="en_US.UTF-8"
SYSFONT="latarcyrheb-sun16"
再备份
[root@oldboy ~]# cp /etc/sysconfig/i18n /etc/sysconfig/i18n.ori
再修改
[root@oldboy ~]# echo ‘LANG="zh_CN.UTF-8"‘>/etc/sysconfig/i18n
[root@oldboy ~]# source /etc/sysconfig/i18n
#使上文修改生效
[root@oldboy ~]# echo $LANG
查看当前字符集状态

6.时间同步
[root@oldboy ~]# echo ‘#time sync by oldboy at 2010-2-1‘>>/var/spool/cron/root
[root@oldboy ~]# echo ‘*/5 * * * * /usr/sbin/ntpdate time.nist.gov >/dev/null 2>&1‘ >>/var/spool/cron/root
[root@oldboy ~]# crontab -l
#time sync by oldboy at 2010-2-1
*/5 * * * * /usr/sbin/ntpdate time.nist.gov >/dev/null 2>&1


7.命令行安全

[root@oldboy ~]# #time sync by oldboy at 2010-2-1
[root@oldboy ~]# echo ‘export TMOUT=300‘ >>/etc/profile
[root@oldboy ~]# echo ‘export HISTSIZE=5‘ >>/etc/profile         
[root@oldboy ~]# echo ‘export HISTFILESIZE=5‘ >>/etc/profile
[root@oldboy ~]# tail -3 /etc/profile

[root@oldboy ~]# . /etc/profile


8.加大文件描述

[root@oldboy ~]# echo ‘*        -       nofile       65535‘ >>/etc/security/limits.conf

[root@oldboy ~]# tail -1 /etc/security/limits.conf 
*        -       nofile       65535


9.内核优化

本文出自 “sandshell” 博客,请务必保留此出处http://sandshell.blog.51cto.com/9055959/1950291

centos模板机制作前修改配置