How to Delete a File in Terminal: Commands, Options, and What to Know First

Deleting files through a graphical interface feels intuitive — drag to trash, empty, done. But the terminal gives you something the GUI doesn't: precision, speed, and the ability to remove files that the interface won't touch. The tradeoff is that terminal deletions are immediate and, in most cases, permanent. Understanding exactly what you're doing before you run the command matters.

The Core Command: rm

On Linux and macOS, the primary command for deleting files in the terminal is rm (short for remove). On Windows, the equivalent commands live in either Command Prompt or PowerShell, with slightly different syntax.