#!/bin/bash
# Program: 对CentOS 6.x的优化配置脚本
# Date: 2016-2-25
# Author: uangianlap
# Version: 1.0
. /etc/init.d/functions
# 关闭selinux
setenforce 0 && sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config
action "关闭selinux成功" /bin/true
# 关闭防火墙
iptables -F &> /dev/null && /etc/init.d/iptables stop &> /dev/null && chkconfig iptables off
action "关闭防火墙成功" /bin/true
# 设置中文显示
cp /etc/sysconfig/i18n{,.ori}
echo 'LANG="zh_CN.UTF-8"' > /etc/sysconfig/i18n
source /etc/sysconfig/i18n
action "设置中文显示成功" /bin/true
# 只保留有限几个开机自启动服务
for name in sshd network rsyslog crond sysstat;do chkconfig --add $name && chkconfig $name on;done
for name in `chkconfig --list| awk '{print $1}' | grep -Ev "sshd|network|rsyslog|crond|sysstat"`;do chkconfig $name off;done
action "开机自启动服务优化成功" /bin/true
# 增大文件描述符
ulimit -SHn 65535
echo "ulimit -SHn 65535" >> /etc/rc.local
action "增大文件描述符成功" /bin/true
# 修改history记录个数及显示格式
sed -i "s/HISTSIZE=1000/HISTSIZE=100/" /etc/profile
source /etc/profile
echo 'export HISTTIMEFORMAT="%F %T `whoami` "' >> /etc/rc.local
source /etc/rc.local
action "History优化成功" /bin/true
# 同步时间
if (yum list installed | grep ntpdate &> /dev/null) && ! (crontab -l | grep "sync time" &> /dev/null);then
echo "#sync time via internet" >> /var/spool/cron/root
echo "00 06 * * * /usr/sbin/ntpdate 202.120.2.101 &> /dev/null" >> /var/spool/cron/root
fi
action "时间同步添加成功" /bin/true
https://www.jianshu.com/p/bd8f115fe347
归档
- 2023年5月
- 2023年3月
- 2023年2月
- 2023年1月
- 2022年10月
- 2022年9月
- 2022年8月
- 2022年7月
- 2022年6月
- 2022年5月
- 2022年4月
- 2022年3月
- 2022年2月
- 2022年1月
- 2021年12月
- 2021年11月
- 2021年10月
- 2021年9月
- 2021年8月
- 2021年7月
- 2021年6月
- 2021年5月
- 2021年4月
- 2021年3月
- 2021年2月
- 2021年1月
- 2020年12月
- 2020年11月
- 2020年10月
- 2020年9月
- 2020年8月
- 2020年7月
- 2020年6月
- 2020年5月
- 2020年4月
- 2020年3月
- 2020年2月
- 2019年12月
- 2019年11月
- 2019年9月
- 2019年8月
- 2019年7月
- 2019年3月
- 2019年2月
- 2019年1月
- 2018年12月
- 2018年11月
- 2018年10月
- 2018年9月
- 2018年8月
- 2018年7月
- 2018年5月
- 2018年4月
- 2018年3月
- 2018年2月
- 2018年1月
- 2017年10月
- 2017年9月
- 2017年8月
- 2017年7月
- 2017年6月
- 2017年5月
- 2017年3月
- 2017年2月
- 2017年1月
- 2016年12月
- 2016年11月
- 2016年10月
- 2016年9月
- 2016年8月
- 2016年7月
- 2016年6月
- 2016年5月
- 2016年4月
- 2016年3月
- 2016年2月
- 2016年1月
- 2015年11月
- 2015年10月
- 2015年9月
- 2015年7月
- 2015年5月
- 2015年4月
- 2015年3月
- 2015年2月
- 2015年1月
- 2014年12月
- 2014年11月
- 2014年10月
- 2014年9月
- 2014年8月
- 2014年7月
- 2014年6月
- 2013年6月
- 2012年11月
- 2011年6月
- 2010年2月
- A gray cat slinks past a wooden house. There’s something a little intimidating attempting to describe.
- Error: Please check if you enter Instagram username and Access Token in Theme Setting > Social Profiles
Leave a reply