ShellCommand Expert
← Back to the explainer

How to Read a Shell Command Safely Before You Run It

Most shell commands are safe. The dangerous ones look almost identical to the safe ones — a single extra flag can turn "list what is here" into "delete what is here". The gap is usually one character, so read before you paste.

Find the command itself

The first word is the program. Everything after it is an option or an argument. If you cannot name the program, that is the first thing to look up — a name like curl, tar or find tells you the family of things it can do before you read a single flag.

Decode the flags

Short flags cluster: -czvf is four separate flags, c then z then v then f. Long flags are self-describing but easy to skim past — --exclude reads as harmless, and mostly is, while --force and --no-preserve-root do not.

If a flag is unfamiliar, run the command with --help first. Most GNU tools print the meaning of every flag; it takes five seconds and it is the difference between reading and guessing.

Look at what it writes, not what it reads

This is the step people skip. A command that only reads is almost always safe; a command that writes changes state, and some writes are hard to undo.

Watch for redirects (>, which truncates a file before the command even runs), -o, -i, --in-place, rm, mv, dd, and tee. sudo in front of any of them raises the stakes, because it is no longer limited by your own permissions.

Check the pipe

In a | b | c, the last command is what actually happens. The earlier ones only produce its input. A pipe of three read-only commands ending in sh executes whatever arrived — so curl … | sh is not a download followed by a shell session, it is a single decision to run a stranger's script.

The safe pattern is to split it: download to a file, read the file, then run it. The content cannot change between the reading and the running, because it is already on your disk.

Explain a command →
Home All guides About Contact Privacy
© 2026 Shell Command Expert