Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Applications > Mac Applications and Mac App Store

Reply
 
Thread Tools Search this Thread Display Modes
Old Jun 27, 2007, 12:28 PM   #1
iBookG4user
macrumors 604
 
iBookG4user's Avatar
 
Join Date: Jun 2006
Location: Seattle, WA
Send a message via MSN to iBookG4user
Terminal command to delete a folder filed with locked files?

I was helping a friend by reformatting his pc and reinstalling windows because it was slow, when I was downloading the drivers for it on my MacBook Pro (didn't have access to the router since it's downstairs and his pc didn't have a wireless card), it downloaded a folder filled with locked files, it comes several folders deep and all of the files are locked, fun. So I tried to delete it using sudo rm -r, but it says I don't have sufficient privileges, anyone know a command I can use to delete it all? I'd rather not do it by hand, that'd take forever.
__________________
*Super high tech stuff goes here*
iBookG4user is offline   0 Reply With Quote
Old Jun 27, 2007, 12:39 PM   #2
theBB
macrumors 68020
 
theBB's Avatar
 
Join Date: Jan 2006
You have to unlock the files and the folders first. This article might help:

http://www.macosxhints.com/article.p...locked%2Bfiles


I guess you will probably have to use one or both of these commands:

chflags nouchg Folder_Name

to unlock the folder (if the folder is locked as well) and


chflags nouchg Folder_Name/*

to unlock the files in the folder
theBB is offline   0 Reply With Quote
Old Jun 27, 2007, 12:43 PM   #3
mkrishnan
Moderator emeritus
 
mkrishnan's Avatar
 
Join Date: Jan 2004
Location: Grand Rapids, MI, USA
Quote:
Originally Posted by iBookG4user View Post
So I tried to delete it using sudo rm -r
No, I think you just need to add an f -- the r makes it recursive (so it can delete a folder and files); the f overrides permissions.

sudo rm -rf

I don't think there should be anything deleterious resulting from doing that. Just be careful to rm -rf the right thing -- there aren't any limits to what it can delete.
__________________
Mohan
mkrishnan is offline   0 Reply With Quote
Old Jun 27, 2007, 12:59 PM   #4
iBookG4user
Thread Starter
macrumors 604
 
iBookG4user's Avatar
 
Join Date: Jun 2006
Location: Seattle, WA
Send a message via MSN to iBookG4user
Quote:
Originally Posted by mkrishnan View Post
No, I think you just need to add an f -- the r makes it recursive (so it can delete a folder and files); the f overrides permissions.

sudo rm -rf

I don't think there should be anything deleterious resulting from doing that. Just be careful to rm -rf the right thing -- there aren't any limits to what it can delete.
Thanks, that worked!
__________________
*Super high tech stuff goes here*
iBookG4user is offline   0 Reply With Quote
Old Jun 27, 2007, 01:10 PM   #5
Cromulent
macrumors 603
 
Cromulent's Avatar
 
Join Date: Oct 2006
Location: The Land of Hope and Glory
Quote:
Originally Posted by OutThere View Post
You need to have -d to remove a directory.

so:

Code:
sudo rm -rfd /yourfolder/
will make it go away, no problems or questions asked
-rf is sufficient. No need for the -d switch.
__________________
Neural Advance - Mac OS X, UNIX and Windows Development
Last.fm Profile | Extreme Metal Reviews
MP 4x 2.66Ghz Xeons / 6GB RAM / 640GB + 500GB + 750GB + 1TB HDDs / ATI Radeon 4870 / iPad 3
Cromulent is offline   0 Reply With Quote
Old Jun 27, 2007, 01:18 PM   #6
OutThere
macrumors 603
 
OutThere's Avatar
 
Join Date: Dec 2002
Location: NYC
Quote:
Originally Posted by Cromulent View Post
-rf is sufficient. No need for the -d switch.
My mistake...I never tried deleting directories without the -d so I thought it was necessary...thanks!
__________________
puisqu'on est jeune et con, puisqu'ils sont vieux et fous. . .
OutThere is offline   0 Reply With Quote
Old Jun 27, 2007, 01:27 PM   #7
mkrishnan
Moderator emeritus
 
mkrishnan's Avatar
 
Join Date: Jan 2004
Location: Grand Rapids, MI, USA
Quote:
Originally Posted by OutThere View Post
My mistake...I never tried deleting directories without the -d so I thought it was necessary...thanks!
I think you use the d switch if you want to delete an empty directory? But I'm not even sure about that. Maybe I'm confabulating from the days of rmdir nonsense.

EDIT: I read back on the -d flag. According to the man page, -d unlinks even non-empty directories when a superuser does it (meaning that sudo rm -df should delete a non-empty directory). I'm a little confused about any consequences for not unlinking the internal files individually, i.e. if there is any adverse impact of sudo rm -df vs. sudo rm -rf. In any event, though, -rf seems safer, since it does actually bother to delete each file.
__________________
Mohan

Last edited by mkrishnan; Jun 27, 2007 at 01:37 PM.
mkrishnan is offline   0 Reply With Quote
Old Oct 19, 2009, 07:49 PM   #8
chkdg8
macrumors 6502
 
Join Date: Oct 2007
Location: Coral Springs, Florida
Just a quick question. When you rm a file through terminal, does it just skip the trash all together?
__________________
20" Aluminum iMac 9G55, 2.4 GHz, 4GB DDR2 RAM, 320GB HDD, SL 10.6.7 // 32GB iPhone 4 iOS 4.3.2
chkdg8 is offline   0 Reply With Quote
Old Oct 19, 2009, 09:11 PM   #9
angelwatt
Moderator emeritus
 
angelwatt's Avatar
 
Join Date: Aug 2005
Location: USA
Quote:
Originally Posted by chkdg8 View Post
Just a quick question. When you rm a file through terminal, does it just skip the trash all together?
Yes.
angelwatt is offline   0 Reply With Quote
Old Oct 19, 2009, 09:20 PM   #10
chkdg8
macrumors 6502
 
Join Date: Oct 2007
Location: Coral Springs, Florida
Quote:
Originally Posted by angelwatt View Post
Yes.
Thank you angelwatt. I just wanted to know the ins and outs of proper file removal and or deletion because I was doing Empty Trash Securely for the past six months. Although this process takes an extremely long time with large files, I went back to trashing normally because 1. I'm the only user and 2. I don't have ultra secret NSA files on my mac that requires secure deletion. Now that I know that a deleted file's space will eventually get erased by something else, I'm all good in knowing that terminal deletes just as good.
__________________
20" Aluminum iMac 9G55, 2.4 GHz, 4GB DDR2 RAM, 320GB HDD, SL 10.6.7 // 32GB iPhone 4 iOS 4.3.2
chkdg8 is offline   0 Reply With Quote
Old Oct 20, 2009, 05:58 AM   #11
angelwatt
Moderator emeritus
 
angelwatt's Avatar
 
Join Date: Aug 2005
Location: USA
Quote:
Originally Posted by chkdg8 View Post
Thank you angelwatt. I just wanted to know the ins and outs of proper file removal and or deletion because I was doing Empty Trash Securely for the past six months. Although this process takes an extremely long time with large files, I went back to trashing normally because 1. I'm the only user and 2. I don't have ultra secret NSA files on my mac that requires secure deletion. Now that I know that a deleted file's space will eventually get erased by something else, I'm all good in knowing that terminal deletes just as good.
In case you ever need it there's also a srm command that does a secure removal, which is the same as a secure empty trash, I think. Do a "man srm" to see the other options, like for using only a 1-pass or 7-pass erase rather than the default 35-pass, which is overkill for most people.
angelwatt is offline   0 Reply With Quote
Old Apr 8, 2011, 02:12 AM   #12
Notsmart
macrumors newbie
 
Join Date: Apr 2011
Cannot Delete Folder

I was unzipping files I had copied from a CD-ROM and had to abort midstream. I now have the incomplete files on my flash drive and cannot delete them. The individual files are locked, and I can delete them individually, but that would take forever. I emptied a few folders of the files, but I cannot delete the folders. The folders do not indicate they are locked when I press command+I. I tried sudo rm -rf. The first time, it asked for a password so I entered my admin password, but nothing happened. I tried it again, even adding the -d switch, but now the message is:

rm: illegal option -- /
usage: rm [-f | -i] [-dPRrvW] file ...
unlink file

How can I get rid of these folders? I cannot reformat the flash drive because I have several other files on it that I need. THANK YOU!!!!
Notsmart is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Applications > Mac Applications and Mac App Store

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Open all files from folder via Terminal vloryan Mac Programming 11 Jan 12, 2014 05:55 PM
Terminal Won't Delete Unlocked Backup Folder in Trash kumquat OS X 10.8 Mountain Lion 0 Apr 15, 2013 12:33 PM
iPhone: Will jailbreaking allow me to delete files in the library/sms folder? guinvere Jailbreaks and iOS Hacks 2 Feb 18, 2013 01:16 PM
Need command in terminal chadteetzen OS X 1 Jun 8, 2012 10:55 PM

Forum Jump

All times are GMT -5. The time now is 02:04 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC