How to Delete Files/Folders on Mac with Terminal RM Command

Cassie Xie
Last updated: Sep 13, 2024
Summary: You can delete files or folders on Mac with Terminal. Check the step-by-step guide in this post.

macOS includes a built-in Terminal app. You can use Terminal commands to do various tasks on your Mac. Learn how to delete files on Mac using Terminal.

delete files on Mac with Terminal

How to Delete Files on Mac with Terminal

  1. Open the Terminal app via Spotlight. Or, click Finder > Applications > Utilities > Terminal to open the app.
  2. In Terminal, type the rm command and type a space after it.
  3. Drag the file that you want to delete after the command. Alternatively, manually enter the file path after the “rm” command.
  4. Press Enter, and the file will be permanently deleted from your Mac.
how to delete a file in Terminal

How to Delete Multiple Files in Terminal on Mac

  1. Open Terminal on Mac.
  2. Type the command rm filename.extension. Enter the real file name and extension after the “rm” command. Add the file name and extension of every file that you want to delete one by one, and leave a space between each file.
  3. Press Enter to delete the files with Terminal.
note
Be careful when using Terminal to delete files on Mac, as incorrect commands can lead to permanent data loss. If you can’t delete a file on your Mac, you may also try to force delete the file using Terminal.

How to Delete Folders on Mac Using Terminal

If you want to use Terminal to delete a folder including any files or sub-folders it contains, you can use the “rm” command with the “-r” option. Follow the steps below.

  1. Launch Terminal via Spotlight.
  2. In Terminal, type the command rm -r foldername. Replace “foldername” with the exact name of the folder. If the folder name has spaces, you need to put it in quotes. For instance, rm -r “my folder”.

Delete Files and Free Up Space on Mac with BuhoCleaner

If you can’t delete a file using Terminal or a normal way introduced below, you may try BuhoCleaner which lets you easily delete and shred the file.

BuhoCleaner is a Mac cleaner app to help you clean and speed up your Mac. It allows you to flash scan and clean your Mac, uninstall unwanted apps without leftovers, find and delete large or duplicate files, free up RAM, manage startup items, monitor system resource usage, shred files, and more.

Download and install BuhoCleaner on your Mac and use it to delete files on your Mac.

DownloadFor macOS 10.10 and above
100,000+ Satisfied Users Worldwide
  1. Launch BuhoCleaner
  2. Click Toolkit > Shredder.
  3. Click the Select Files button and select the target file that you want to delete.
  4. Click the Securely Remove button to permanently delete the file from your Mac.
Delete Files on Mac with BuhoCleaner

Other Ways to Delete Files or Folders on macOS

Instead of using Terminal to delete files and folders on Mac, you can use some normal ways to delete files.

Via Finder:

  • Open Finder.
  • Select the target file that you want to delete. To select multiple files on Mac, press and hold the Command key and select the files.
  • Press the Delete key to delete the files.

Via keyboard shortcut:

Select the file or folder that you want to delete and press Command + Delete to move it to the Trash. To bypass the Trash and permanently delete the file, press Shift + Command + Delete.

Via Trash:

You can directly drag and drop the file to the Trash icon in the Dock to delete it.

Use Move to Trash:

Right-click the target file or use Control + Click. Select Move to Trash to delete the file.

Conclusion

This post offers a detailed guide on how to delete files on Mac with Terminal. You can use the Mac Terminal rm command or rm -r command to remove a file or folder from your Mac. Some other ways to help you delete files and folders on Mac are also introduced. Hope it helps.

Cassie has been writing about technology for her entire career life - over 5 years. She enjoys diving into how Apple products work and then breaking it down in a way anyone can understand.