服务器运维笔记
记录一些常用的服务器运维命令和技巧。
系统信息
# 查看系统版本
cat /etc/os-release
# 查看内存
free -h
# 查看磁盘
df -h
# 查看 CPU
lscpu
网络相关
# 查看端口占用
ss -tlnp
# 查看防火墙状态
ufw status
# 测试端口连通性
curl -I http://example.com
服务管理
# 查看服务状态
systemctl status nginx
# 重启服务
sudo systemctl restart nginx
# 查看日志
journalctl -u nginx -f
安全建议
- 禁用密码登录 - 使用 SSH Key
- 限制 SSH 来源 IP - 只允许可信 IP
- 定期更新 -
apt update && apt upgrade - 配置防火墙 - 只开放必要端口
持续更新中…