← 返回
AI智能
中文
Linux
Operate Linux systems avoiding permission traps, silent failures, and common admin mistakes.
操作Linux系统,避免权限陷阱、静默失败及常见管理错误。
ivangdavila
AI智能
clawhub
v1.0.0 1 版本 98995.4 Key: 无需
#latest
概述
Linux Gotchas
Permission Traps
chmod 777 fixes nothing, breaks everything — find the actual owner/group issue- Setuid on scripts is ignored for security — only works on binaries
chown -R follows symlinks outside target directory — use --no-dereference- Default umask 022 makes files world-readable — set 077 for sensitive systems
- ACLs override traditional permissions silently — check with
getfacl
Process Gotchas
kill sends SIGTERM by default, not SIGKILL — process can ignore itnohup doesn't work if process already running — use disown instead- Background job with
& still dies on terminal close without disown or nohup - Zombie processes can't be killed — parent must call wait() or be killed
kill -9 skips cleanup handlers — data loss possible, use SIGTERM first
Filesystem Traps
- Deleting open file doesn't free space until process closes it — check
lsof +L1 rm -rf /path / with accidental space = disaster — use rm -rf /path/ trailing slash- Inodes exhausted while disk shows space free — many small files problem
- Symlink loops cause infinite recursion —
find -L follows them /tmp cleared on reboot — don't store persistent data there
Disk Space Mysteries
- Deleted files held open by processes —
lsof +L1 shows them, restart process to free - Reserved blocks (5% default) only for root —
tune2fs -m 1 to reduce - Journal eating space —
journalctl --vacuum-size=500M - Docker overlay eating space —
docker system prune -a - Snapshots consuming space — check LVM, ZFS, or cloud provider snapshots
Networking
localhost and 127.0.0.1 may resolve differently — check /etc/hosts- Firewall rules flushed on reboot unless saved —
iptables-save or use firewalld/ufw persistence netstat deprecated — use ss instead- Port below 1024 requires root — use
setcap for capability instead - TCP TIME_WAIT exhaustion under load — tune
net.ipv4.tcp_tw_reuse
SSH Traps
- Wrong permissions on ~/.ssh = silent auth failure — 700 for dir, 600 for keys
- Agent forwarding exposes your keys to remote admins — avoid on untrusted servers
- Known hosts hash doesn't match after server rebuild — remove old entry with
ssh-keygen -R - SSH config Host blocks: first match wins — put specific hosts before wildcards
- Connection timeout on idle — add
ServerAliveInterval 60 to config
Systemd
systemctl enable doesn't start service — also need startrestart vs reload: restart drops connections, reload doesn't (if supported)- Journal logs lost on reboot by default — set
Storage=persistent in journald.conf - Failed service doesn't retry by default — add
Restart=on-failure to unit - Dependency on network:
After=network.target isn't enough — use network-online.target
Cron Pitfalls
- Cron has minimal PATH — use absolute paths or set PATH in crontab
- Output goes to mail by default — redirect to file or
/dev/null - Cron uses system timezone, not user's — set TZ in crontab if needed
- Crontab lost if edited incorrectly —
crontab -l > backup before editing - @reboot runs on daemon restart too, not just system reboot
Memory and OOM
- OOM killer picks "best" victim, often not the offender — check dmesg for kills
- Swap thrashing worse than OOM — monitor with
vmstat - Memory usage in
free includes cache — "available" is what matters - Process memory in
/proc/[pid]/status — VmRSS is actual usage - cgroups limit respected before system OOM — containers die first
Commands That Lie
df shows filesystem capacity, not physical disk — check underlying devicedu doesn't count sparse files correctly — file appears smaller than disk usageps aux memory percentage can exceed 100% (shared memory counted multiple times)uptime load average includes uninterruptible I/O wait — not just CPUtop CPU percentage is per-core — 400% means 4 cores maxed
版本历史
共 1 个版本
-
v1.0.0
当前
2026-03-28 14:24 安全 安全
安全检测
腾讯云安全 (Sanbu)
安全,无风险
查看报告
🔗 相关推荐
ai-intelligence
halthelobster
将AI智能体从任务执行者升级为主动预判需求、持续优化的智能伙伴。集成WAL协议、工作缓冲区、自主定时任务及实战验证模式。Hal Stack核心组件 🦞
★ 833
📥 212,776
ai-intelligence
oswalpalash
类型化知识图谱,用于结构化智能体记忆与可组合技能。支持创建/查询实体(人员、项目、任务、事件、文档)及关联...
★ 709
📥 243,527
ai-intelligence
ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,349
📥 317,697