5 Linux Commands That Instantly Destroy Your Server (And How to Protect Yourself)
1. Stopping Fork Bombs with PAM Limits You can prevent any user from spawning millions of processes by configuring maximum process counts (nproc) in /etc/security/limits.conf: # Prevent fork bombs: limit maximum con
1. Stopping Fork Bombs with PAM Limits
You can prevent any user from spawning millions of processes by configuring maximum process counts (nproc) in /etc/security/limits.conf:
# Prevent fork bombs: limit maximum concurrent processes per user
* hard nproc 2000
* soft nproc 1000
www-data hard nproc 500
With this configuration active, if an unprivileged user or web application attempts to run a fork bomb, the kernel stops spawning child processes at 2,000. The user session displays an error, but the rest of the server and other users remain completely unaffected.
2. Safe Shell Aliases
To avoid accidental file deletion through typo errors, configure interactive confirmation flags in your global or user shell profile (~/.bashrc):
# Require confirmation before destructive actions
alias rm='rm -I'
alias cp='cp -i'
alias mv='mv -i'
3. Least Privilege and Read-Only Mounts
-
Never log in directly as root: Use unprivileged user accounts and prepend
sudoonly when administrative capabilities are required. -
Mount sensitive partitions read-only: In production environments, mount directories like
/bootas read-only (roin/etc/fstab) to prevent accidental overwrites during daily operations.
- Maintain Off-Site Automated Backups: The only true defense against root-level drive destruction is a tested, air-gapped backup strategy.
Related Guides on LinuxPedia
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.