Linux CentOS 6.11:系统优化与使用技巧
简介

CentOS 6.11是CentOS 6系列的一个稳定版本,它基于Red Hat Enterprise Linux 6.11构建,本文将介绍如何在CentOS 6.11上进行系统优化,以及一些实用的使用技巧。
系统优化
关闭不必要的系统服务
CentOS 6.11默认启动了大量的系统服务,这些服务可能会占用系统资源,影响系统性能,以下是一些可以关闭的服务:
| 服务名称 | 说明 |
|---|---|
| cups | 打印服务 |
| avahi-daemon | Bonjour服务,用于网络邻居发现 |
| bluetooth | 蓝牙服务 |
| NetworkManager | 网络管理服务 |
| cups | 打印服务 |
| avahi-daemon | Bonjour服务,用于网络邻居发现 |
| bluetooth | 蓝牙服务 |
| NetworkManager | 网络管理服务 |
关闭服务的方法:
systemctl stop 服务名称 systemctl disable 服务名称
优化内核参数
编辑/etc/sysctl.conf文件,添加以下内容:

net.ipv4.tcp_fin_timeout = 30 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_tw_recycle = 1 net.ipv4.tcp_keepalive_time = 600
然后使用以下命令使配置生效:
sysctl -p
优化SSH服务
编辑/etc/ssh/sshd_config文件,修改以下参数:
Port 22 PermitRootLogin no PasswordAuthentication no ChallengeResponseAuthentication no UsePAM no
然后重启SSH服务:
systemctl restart sshd
使用技巧
使用Yum安装软件
yum install 软件包名
使用Yum源加速

编辑/etc/yum.repos.d/CentOS-Base.repo文件,将以下内容替换为国内的Yum源:
[base] name=CentOS-$releasever - Base mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=Base&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 [epel] name=Extra Packages for Enterprise Linux 7 - x86_64 mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=epel&infra=$infra #baseurl=http://dl.fedoraproject.org/pub/epel/7/x86_64/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
使用Nginx作为Web服务器
yum install nginx systemctl start nginx systemctl enable nginx
FAQs
如何查看系统版本?
cat /etc/redhat-release
如何查看CPU信息?
cat /proc/cpuinfo

