Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'this can be done form the Terminal' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
this can be done form the Terminal
Authored by: Anonymous on Mar 28, '01 04:09:21PM
I've run into this same problem, where I couldn't delete a file because osX thought it was in use. If the file hasn't yet been moved to the trash, try to log into the terminal as root and use the rm command to delete it. Be careful that you're deleting the correct file, as by default rm does not ask for confirmation. You can use tab-completion to get osX to insert the filename for you. ie to delete a file called My File Is Locked, you could do this:

rm "My (then hit the tab key) " (put an endquote in there also)


Make any sense? also, if your file is already in the trash, you can search for it with sherlock, and then drag the icon to the Terminal - it's full path wil pop up, allowing for easy deletion.

Be careful with rm!



[ Reply to This | # ]
re: this can be done form the Terminal
Authored by: Anonymous on Mar 28, '01 07:23:02PM

that's not actually the case with locked files.

if the file is locked, then when you try to rm, even as root, it prompts
"override <permissions> for <filename>?"
hitting y for yes returns
"rm: <filename>: Operation not permitted"
and the file stays there.



[ Reply to This | # ]
re: this can be done form the Terminal
Authored by: alanw on Apr 14, '01 01:11:16AM

It is true that even as root via the Terminal you cannot use the usual UNIX "rm" command to delete locked files. This is disturbing (especially unsettling to one who has done Mac troubleshooting for years and is well acquainted with Murphy's Law--if something can go wrong, it will). Suppose that by whatever cause, malicious or otherwise, you find your disks filled with hundreds or thousands of locked files. There should be some backdoor method (certainly, I agree, not one to be invoked casually) to unlock them in batch fashion (apart from rebooting into Mac OS 9.1; perhaps someday that won't be an option).
Well, after puzzling over this for some time, I finally discovered that backdoor method. You need to have the Developer Tools installed. Open a Terminal window and type (without the quotes)
"/Developer/Tools/SetFile a -l <names of files to unlock>" You can use wildcards. "/Developer/Tools/SetFile a -l *" for example will unlock all files in the current directory. If some are already unlocked, their lock attribute remains unchanged. Experienced UNIX hackers will no doubt be able to use shell scripts or more complicated command combinations to unlock in batch fashion any files anywhere.



[ Reply to This | # ]
re: this can be done form the Terminal
Authored by: alanw on Apr 14, '01 01:19:34AM

Correction: That should have been "/Developer/Tools/SetFile -a l <names of files>" and
"/Developer/Tools/SetFile -a l *"
I knew I shouldn't have stayed up this late. :-)



[ Reply to This | # ]
re: this can be done form the Terminal
Authored by: sauy7 on Oct 30, '04 06:39:48AM
Here's a simple bash script to run in a Terminal window

#! /bin/bash
#
# Simple file unlocking utility for Mac OS X
#
ARGS=1
E_BADARGS=65

function recursiveUnlock() {
    pushd $1
    for rdir in `ls -A`; do
        if [ -d "${rdir}" ]; then
            recurse ${rdir}
        else
            /Developer/Tools/SetFile -a l ${rdir}
        fi
    done
    popd
}

if [ $# -ne "$ARGS" ]
then
    echo "Usage: `basename $0` starting-directory"
    exit $E_BADARGS
fi

recursiveUnlock $1
Usage (code saved as an excutable file recursiveUnlock.sh):

$ ./recursiveUnlock.sh /path/to/top-level/dir
unlocks all files in dir, including those in dir's sub-directories

---
sauy7

[ Reply to This | # ]

re: this can be done form the Terminal
Authored by: gwik on Mar 01, '06 09:55:25AM
$ find *the_root_dir* -type d -exec /Developer/Tools/SetFile -a l {} \;

[ Reply to This | # ]
this can be done form the Terminal
Authored by: rodrat on Dec 09, '02 05:39:58PM

To trash a locked file,I found the problem is hidden files. control
click on the folders that won't open and click on reveal to open folder.
Then unlock hidden file with GETINFO!



[ Reply to This | # ]
this can be done form the Terminal
Authored by: rodrat on Dec 09, '02 05:42:59PM

To trash a locked file,I found the problem is hidden files. control
click on the folders that won't open and click on reveal to open folder.
Then unlock hidden file with GETINFO!



[ Reply to This | # ]
this can be done form the Terminal
Authored by: tolba on Apr 10, '06 07:32:19PM

I have tried almost every suggestion I have seen to delete a particular file. This file is on an external hard drive, it is locked and no matter what I do it will not go away. It is not a virus it is a fractal software program. I will take all the help I can get. Please be gentle I am new at this terminal window thing.

thanks
tolba



[ Reply to This | # ]