Debian系统管理实战指南
一、服务管理核心技巧
1. systemctl命令大全
1 2 3 4 5 6 7 8
| systemctl status -l --no-pager sshd
journalctl -u nginx -f
systemctl set-property apache2 CPUQuota=60% MemoryMax=1.5G
|
2. 服务单元文件模板
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| [Unit] Description=High Priority Service After=network.target StartLimitIntervalSec=30s StartLimitBurst=5
[Service] Type=simple ExecStart=/usr/bin/myapp Restart=on-failure RestartSec=5s
[Install] WantedBy=multi-user.target
|
二、安全加固方案
1. 基础防护配置
1 2 3 4 5
| sudo mount -o remount,ro /usr/
systemd-analyze security sshd
|
2. 高级安全单元配置
1 2 3 4 5 6
| [Service] ProtectSystem=strict PrivateTmp=yes NoNewPrivileges=yes RestrictSUIDSGID=yes MemoryDenyWriteExecute=yes
|
三、故障排查工具箱
1. 启动过程分析
1 2 3 4 5
| systemd-analyze plot > boot_analysis.svg
systemd-analyze blame --no-pager
|
2. 资源监控命令
1 2 3 4 5
| systemd-cgtop -n 10 -d 2
journalctl -u myservice --grep="out of memory"
|
四、Debian版本差异
| 特性 |
Debian 11 |
Debian 12 |
| 默认init系统 |
systemd 247 |
systemd 252 |
| 安全特性 |
基础SELinux支持 |
完整SELinux集成 |
| 资源限制 |
简单cgroup配置 |
精细化资源调控 |
请复制以上内容保存为Debian管理指南.md,如需任何格式调整或补充内容请随时告知!