'rm'ing locked files

daver969

Registered
rm -f filename won't remove a file if it's locked, is there any way to get around this? Perhaps by logging in as root? If so, how do I get crontab to run a script as root instead of as me?
 
do th:

sudo rm -f

It will ask you for a passowrd (your password) but it will delete the file :)
This what I hate in OS X since the PB. I was so used to being THE root in PB, but now its gone... I havent customized my OS X enough to gimme back my full root privs to my UID :p

Admiral
 
It didn't work, I think the problem may be that the "locked"ness comes from osX, and is not an inherent part of unix. Any other ideas?
 
This is probably the good ol' immutable flag deal; run

Code:
sudo chflags nouchg <filename>

then rm it.
 
Though I haven't tested it, in 10.1 they modified the "rm" command so that it will override the uchg bit and remove the files.

Wade
 
Hi,
my brother had a problem where his whole User-folder was locked, all files have the immutable flag set.
Probably came from running Norton in OS9, he has both OSs on the same partition.
One can change this with chflags, but this will take a long time applying this to all files.
Is there a way to chflag all files in a folder?

thanks,
 
Yup, the recursive (-R) flag:

Code:
sudo chflags -R nouchg /path/to/folder

will do the folder and all contents.
 
Back
Top