#安装常用工具,添加国内源
yum install wget net-tools -y
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
#关闭selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
setenforce 0
getenforce
#关闭防火墙,centos7已默认关闭
/etc/init.d/iptables stop
chkconfig iptables off
#关闭无用的自启进程
chkconfig|egrep -v "crond|sshd|network|rsyslog|sysstat"|awk '{print "chkconfig",$1,"off"}'|bash
chkconfig --list|grep 3:on
#时间同步
echo '*/5 * * * * /usr/sbin/ntpdate cn.ntp.org.cn >/dev/null 2>&1' >>/var/spool/cron/root
echo '* - nofile 65535 ' >>/etc/security/limits.conf
yum install lrzsz nmap tree dos2unix nc -y
yum install wget net-tools -y
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
#关闭selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
setenforce 0
getenforce
#关闭防火墙,centos7已默认关闭
/etc/init.d/iptables stop
chkconfig iptables off
#关闭无用的自启进程
chkconfig|egrep -v "crond|sshd|network|rsyslog|sysstat"|awk '{print "chkconfig",$1,"off"}'|bash
chkconfig --list|grep 3:on
#时间同步
echo '*/5 * * * * /usr/sbin/ntpdate cn.ntp.org.cn >/dev/null 2>&1' >>/var/spool/cron/root
echo '* - nofile 65535 ' >>/etc/security/limits.conf
yum install lrzsz nmap tree dos2unix nc -y
该博客介绍了Linux系统优化的操作,包括安装常用工具并添加国内源,关闭selinux、防火墙和无用自启进程,进行时间同步等,还给出了具体的命令代码,有助于提升Linux系统的性能和使用体验。

被折叠的 条评论
为什么被折叠?



