rm -rfRecursive, forced, no confirmation, no undo. On most systems rm does not even use a trash folder — it unlinks the directory entry and the blocks become reclaimable.
The safe alternative: run rm -r without -f so it still prompts on write-protected files, or list first with find <path> -depth -print and read what would go.
A variable that expands to empty turns rm -rf "$DIR"/* into rm -rf /*. Always quote and always check: echo "$DIR" before you trust it.
find … -delete and -exec rm {} +Both delete every match of the preceding expression. The expression is the part that is easy to get subtly wrong — a missing -maxdepth or an operator precedence surprise widens the match set.
The safe alternative: run the identical find with -print instead of the action, and read the list. If it is not exactly what you expected, nothing has been deleted yet.
sed -i and perl -iIn-place edit: the file is rewritten and the original is gone. On some platforms a second file may be left behind, but the original content is not recoverable from it in general.
The safe alternative: pass a backup suffix — sed -i.bak — so a copy survives, or redirect to a new file and compare with diff before replacing anything.
ddCopies blocks from one device to another with no safety rails. of=/dev/sdX writes raw blocks over whatever partition table or filesystem was there. It does not check that the target is empty, mounted, or even the disk you meant.
The safe alternative: identify the device by serial number, not by /dev/sdX letter, which changes between boots. And read the command back with the device names resolved before you press enter.
chmod -R 777Makes an entire tree world-readable, world-writable and world-executable. On a web root it means any local user can modify what the server serves.
The safe alternative: set the narrowest permission that works — usually 755 for directories and 644 for files — and apply it to a subtree you have identified, not the filesystem root.
truncate -s 0 and > fileBoth reduce a file to zero length immediately. The redirect form is the trap, because it happens at shell level before the command on the left even starts — so important.conf > important.conf empties the file and then hands the command an empty input.
The safe alternative: write to a temporary file and move it into place, so the original survives until the replacement is complete.
Explain a command →