How to Delete a File in Terminal on Your Mac

Use the command line to permanently delete files from a Mac

Woman's finger hovering above a Mac keyboard ready to push a key

Maskot / Getty Images

Everyone wants to save time and effort when completing tasks on their Mac. Thanks to the command line Terminal, Mac users can easily complete tedious tasks in just a few seconds, including deleting files.

In this guide we'll tell you how to delete a file in Terminal.

The instructions in this article apply to Mac users using 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 and allows users to modify settings, files, and other features beyond what is available in the graphical user interface (GUI). The command line offers users total command of their Mac, from the inside out.

Why should you use Terminal? Here are only 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 much easier to use due to its similarity.
  • It allows you to unlock all preference settings: Everything you can possibly customize can be unlocked using Terminal, even things you can't access through your GUI.
  • It cuts down on clicks: Want to move all of 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 them manually.
  • It helps you remove files with ease–forever: 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.

It's critical to understand that the Terminal is a dangerous place for those who are inexperienced in the command line. Before you enter Terminal, be sure to 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 simply 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 space. Next, you can simply drag and drop the file you want to delete into the Terminal window.

    Deleting a file using Terminal on Mac
  3. Press Enter and the file will be gone forever.

    Want to go even faster? You can also remove the file by entering the path to the file into Terminal yourself, without the drag and drop.

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