How to Delete a File in Terminal on Your Mac

Use the command line to permanently delete files from a Mac

What to Know

  • In a Finder window, go to Applications > Utilities, type rm, space, drag the file to the Terminal window, and press Enter.
  • You can also press Command+Space to open Spotlight, type terminal, and press Enter to access the Terminal window.

In this guide, we show you how to delete a file in Terminal on Mac computers with macOS and OS X Lion (10.7) and later.

What Is Terminal?

Terminal is an app that comes with every Mac. It's a way to use the command line on the Mac. It allows you to modify settings, files, and other features beyond what is available in the graphical user interface (GUI). The command line offers you total command of your Mac, from the inside out.

Why should you use Terminal? Here are a few of the key benefits of using Terminal for Mac:

  • It rings true to Unix: Mac users coming over from Unix will find Terminal easier to use due to its similarity.
  • It allows you to unlock all preference settings: Everything you can customize can be unlocked using Terminal, even things you can't access through the GUI.
  • It cuts down on clicks: Want to move all your files from one folder to another? A few seconds of typing in Terminal is all you need, versus the time and clicks it takes to transfer files manually.
  • It helps you remove files with ease: If you want to remove a file from your Mac forever, you can skip the Trash and use Terminal. It's quick, only taking a few seconds.

The Terminal is a dangerous place if you're inexperienced in the command line. Before you enter Terminal, familiarize yourself with the basic commands. One wrong command can damage your system.

How to Delete a File in Terminal on Your Mac

Whether you're dealing with a problem file that refuses to leave your Mac or you want to delete multiple files quickly, Terminal makes it quick and easy. Here's how:

  1. Navigate to Terminal on your Mac by opening a Finder window and selecting Applications > Utilities.

    You can also press Command+Space to open Spotlight. Then, type terminal and press the Enter key.

    Terminal window on Mac
  2. In the Terminal window, type rm and a space. Next, drag the file you want to delete into the Terminal window.

    Deleting a file using Terminal on Mac
  3. Press Enter, and the file is gone forever.

    Want to go faster? Remove the file by entering the path to the file into Terminal, without the drag and drop.

There you have it. Harness your new power to delete files easily, but remember to use it with care.

FAQ
  • How do I delete multiple files at once from Terminal?

    In Terminal, type in rm [FILENAME].[EXTENSION] followed by the filename and extension of every other file you want to delete—leaving a space between each entry. So it should look something like "rm [FILE1].[EXTENSION] [FILE2].[EXTENSION] [FILE3].[EXTENSION]" and so on.

  • How do I delete a hidden file using Terminal?

    First you'll want to "un-hide" or reveal the files. Type in defaults write com.apple.Finder AppleShowAllFiles TRUE and press return, then type in killall Finder and press return again. Once the files are revealed you can delete them either by typing in rm [FILENAME].[EXTENSION] or typing rm and then dragging and dropping the file icon into Terminal, then pressing return.

Was this page helpful?