Linux executes destructive commands without warning. Understanding which commands are dangerous — and why — helps prevent accidental data loss or system damage.
1. rm -rf /
rm -rf /
Recursively deletes every file on the system starting from root. Modern Linux distributions block this with a --no-preserve-root requirement, but it remains an irreversible catastrophe if run.
2. Fork Bomb
:(){ :|:& };:
A shell function that calls itself recursively in the background. Rapidly exhausts process table and memory, crashing the system. Mitigate by setting limits in /etc/security/limits.conf.
3. Overwrite Disk with /dev/zero or /dev/random
dd if=/dev/zero of=/dev/sda
Overwrites the entire disk with zeros, destroying all data and the partition table. Used intentionally for secure erasure, but devastating when run on the wrong device.
4. Piping wget/curl Output to Shell
wget -O- https://example.com/script.sh | sh
Downloads and executes a remote script with no review. If the remote host is compromised or the URL changes, this can install malware. Always download first, inspect, then execute.
5. mv Directory to /dev/null
mv /home/user /dev/null
Moves files into a black hole — they are unrecoverable. Always use rm intentionally rather than redirecting to /dev/null.
6. chmod -R 777 /
chmod -R 777 /
Makes every file on the system world-writable. Completely destroys security model. Use targeted permission changes only.
7. Redirect Output to an Existing File Without Backup
command > /etc/important-config.conf
The > redirect truncates the file before writing. If the command fails or produces no output, the original file is lost. Use >> to append, or back up first.
8. Downloading and Running Unknown Scripts as Root
sudo bash /tmp/unknown_script.sh
Running scripts obtained from untrusted sources as root grants them full system access. Always read and understand a script before executing it with elevated privileges.
Safe Practices
- Test destructive commands on non-production systems first.
- Use
echo before destructive commands to preview what they will do.
- Back up critical data before any system operation.
- Avoid running as root unless absolutely necessary — use
sudo for specific commands.
- Set
ulimit -u 100 to limit fork bombs for normal users.