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
- Open
Terminal.app -
Type
rm -rf - Highlight files/folders you want to delete
- Drop them all to Terminal
- Execute it (pressing
)
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?



6 COMMENTS (RSS)
Dylan
June 3rd, 2008 Time: 07:21 AM
Make sure you don't type sudo rm -f/, it wipes your hard drive.
Evan
June 3rd, 2008 Time: 07:57 AM
Yeah, that could turn out badly.
Patrix
June 3rd, 2008 Time: 01:10 PM
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
June 3rd, 2008 Time: 01:50 PM
rm -rf is forcing files to be deleted recursively.
Chris
June 6th, 2008 Time: 11:13 PM
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
June 18th, 2008 Time: 01:33 AM
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.
LEAVE.A.COMMENT