系统优化与安全

1 查看系统的版本号

cat /etc/redhat-release
# 或者
hostnamectl

2 查看系统内核版本

# 显示所有内核信息
uname -a
# 只显示内核版本号
uname -r

3 系统时间同步

  • 硬件时间(BIOS 时间)

  • 系统时间(操作系统时间)

硬件时间和系统时间必须一致。

3.1 查看系统时间

date
    +%F  # 只显示年月日 
    +%F-%H-%M-%S  # 显示年月日、时、分、秒 
    -s <datetime> # 手动设置系统时间
Thu Sep  4 19:46:36 CST 2025
# CST(China Standard Time) 中国标准时间
# 比 UTC(Coordinated Universal Time, 协调世界时) 晚 8 小时

3.2 查看硬件时间

3.3 同步系统时间

ntpdate 同步系统时间

hwclock 同步硬件时间

4 关闭 SELinux

SELinux(Security-Enhanced Linux) 是美国国家安全局(NSA)开发的安全子系统。

查看 SELinux 状态:

临时关闭 SELinux:

永久关闭 SELinux:

修改文件 /etc/selinux/configSELINUX参数设置为disabled,重启生效。

5 关闭防火墙

查看防火墙状态:

7 SSH 远程连接优化

禁用 DNS 反向解析

修改配置文件:/etc/ssh/sshd_config,跳转至 115 行,将 UseDNS 参数改为 yes:

重启 ssh 服务:

8 字符集优化

9 bash 命令补全

最后更新于