UsingMac.com

Mac Tricks and Tips, Wallpapers and Applications for Mac Users

Delete Files without Going to Trash Folder

Advertisements

Warning: The deleted files are not recoverable.

This is just a simple and quick UNIX tip to delete files without going to trash folder first. What are the steps?

Delete Normal Files

  1. Open Terminal.app
  2. Type rm -rf
  3. Highlight files/folders you want to delete
  4. Drop them all to Terminal
  5. Execute it (pressing Return)

For example, if you are going to delete 3 files named Delete Me, Crush Me, and Kill Me, the Terminal command lines to execute the deletion will be

rm -rf /Users/wendy/Desktop/Delete\ Me /Users/wendy/Desktop/Crush\ Me /Users/wendy/Desktop/Kill\ Me

It's difficult and not recommended to type all the paths and filenames manually (the complexity of the line can be seen from example above).

Delete Locked Files

Some files are locked. In order to delete locked files, the steps are the same, except that you will need to use Terminal command line :

sudo rm -rf

And you will need admin password. Is this tip useful?

Categories: UNIX, Open Source
Tags: Delete, Finder, Folder, Terminal

Subscribe to RSS Leave a Comment (10)

Related Entries

Some articles taken from our resource base, tightly related to current article, to empower you with more knowledge on tweaking the most out of your Mac.

10 Comments

Dylan

Make sure you don't type sudo rm -f/, it wipes your hard drive.

Evan

Yeah, that could turn out badly.

Patrix

rm -r deletes recursively and it is generally not a good idea to use -r if you don't intend to delete directories (or packages like an MacOSX application).

@Dylan: The command to wipe your drive is actually "rm -r /"

Wendy

rm -rf is forcing files to be deleted recursively.

Chris

Talk about handing someone a loaded weapon...

rm -rf or even rm -r is quite destructive and I wouldn't recommend taking it lightly as you could very well wipe out large portions of your personal files if run as a normal user.

If you combine this with sudo you could very well wipe out large portions of your personal files, system files, and potentially other people's personal files.  Heck you could clean out anything even mounted on your machine locally and even on network drives if the admin of the drives wasn't strict enough with permissions.  Those of you who don't make a habit of working on the command line, please don't take sudo lightly.

Also, while I don't personally use time machine, if your time machine volume happens to be mounted in /Volumes, a misplaced rm -rf / would also wipe your time machine backups out if they are mounted as a normal file-system.  

As a rule, I tend not to use -f unless I need it, and I'd recommend that new users get themselves into a habit of using -i or at the very least -I (if its available on Mac, don't have one in front of me at the moment).  The -i option will prompt you when it descends into a directory and for each file it deletes.  If you run rm without any aliases be sure about every single thing you type.

Alex Fairchild

I tried using the sudo rm -rf command to delete an external hd alias that was locked that wasn't linked to anything. Terminal gave me this error:
rm: /Volumes/MediaBox: Device not configured

any suggestions to either go about fixing this or otherwise deleting this alias would be much appreciated.

Rafael Rinaldi

How I set password check to some folder?

Gary Edwards

Top tip, add this to your .profile:

alias rm='rm -i'

This will mean 'rm' will always ask for conformation before deleting a file. If you want to delete a lot of files and you are sure it's ok then you can always run 'yes | rm <rm args>'

Poko

Oui, je suis d'accord que chaque professionnel devrait se soucient de leur réputation en ligne. медицинская доска объявлений Plus vous avez réussi dans ma région les plus vulnérables à la réputation en ligne. Il semble que ceux qui n'ont pas été couronnés de succès amer et commencer à répandre des rumeurs à votre sujet. Женские журналы и сайты Aucun bavardage en ligne peut me tient plus. Merci à vous,

Polk

Très bonnes idées. После инсульта Surtout pour moi personnellement / site intéressant et utile. Je vais revenir souvent, peut-être quelque chose d'autre seront utiles. Je vous remercie Très faits intéressants à propos du Dalaï Lama. Bien sûr, de prendre des mesures, vous avez besoin d'en savoir plus sur le dalaï-lama. улучшение памяти Et ce site nous aidera grandement

Leave a Comment