为确保Ubuntu系统免受漏洞威胁,可按以下步骤进行全面安全检查:
sudo apt update && sudo apt upgrade 安装最新安全补丁,启用自动更新(unattended-upgrades工具)确保持续修复漏洞。uname -r 查看内核版本,对比官方支持的安全版本,使用 sudo apt install canonical-livepatch 启用内核热补丁(如适用)。sudo lynis audit system。/etc/passwd 和 /etc/shadow 中的用户权限,确保无异常账户;使用 sudo chmod 600 /etc/passwd 保护敏感文件。nmap -sP 192.168.1.0/24 扫描开放端口,关闭非必要服务(如 sudo systemctl disable <服务名>)。ufw 防火墙,限制仅允许SSH等必要端口访问:sudo ufw allow 22/tcp && sudo ufw enable。/var/log/auth.log(登录记录)、/var/log/syslog(系统事件),使用 grep "error" /var/log/syslog 筛选异常。htop 或 glances 监控进程与资源使用,及时发现异常行为。/etc/ssh/sshd_config,禁用root登录(PermitRootLogin no)、启用密钥认证,更改默认端口。fsck 检查文件系统完整性,敏感数据加密存储。操作建议:定期(每周/每月)执行上述检查,重点关注官方安全公告(如Ubuntu Security Notices),确保系统始终处于最新安全状态。