Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Sal Collaziano

macrumors 6502
Original poster
Nov 7, 2007
331
24
Royal Palm Beach, FL
I need to delete a file that I cannot access via Finder. Is there a command that I can use in terminal to delete it? I cannot access the folder the file exists in via Finder..

The file is in /usr/local/

Thanks in advance...
 
the command that you want is "rm", but do be very careful with this :)

rm /usr/local/filename

in the terminal type -
man rm

for more information.
 
"cd" into the directory
"ls" to list contents
"rm" individual files?

then try to remove the directory again?

sorry i can't help much!
 
sudo rm -r foldername
deletes folder and all contents. be careful with it!
 
"cd" into the directory
"ls" to list contents
"rm" individual files?

then try to remove the directory again?

sorry i can't help much!

This was working on directories inside the folder - but not the regular files...

sudo rm -r foldername
deletes folder and all contents. be careful with it!

This worked.. Thank you. I appreciate all the advice I received in this discussion. Hopefully it'll serve many down the road. :)
 
Hey guys. I know this is an old thread, but I found it while trying to figure out one of my own problems and it seems like it is going to lead me in the right direction.

I allowed one of my friends to use my external drive to copy some stuff I had on there. He has a PC that is apparently infected with a .scr virus.

Obviously the file isn't going to mess up anything on my macbook, but I'm not sure about my Toshiba external hard drive. It has already made a bunch of useless copies of random nonsensical files on my drive and I want to get rid of it before it messes up any of the information I have on there.

I tried sudo rm -r /volumes/volumename/filename and got the password prompt. Then it returned 'override rwxrwxrwx _unknown/_unknown arch,uchg,hidden for /volumes/[volumename]/[filename]?'

Any ideas on how to continue on from here? Or what I may have done wrong?

I appreciate any and all help

EDIT

Also, I responded yes to the override and it returned 'Operation not permitted'

Sorry to leave that part out originally.
 
Last edited:
In that message you can see "uchg", which is the "user immutable" flag. I don't think it will let you delete it with that flag. To turn it off, use the chflags command:

Code:
chflags nouchg <filename>

You might also want to know about the -f flag for the rm command. It will answer "yes" to all of the questions so you don't get prompted. For example

Code:
sudo rm -rf /

will delete all files on your system without asking for any confirmation. So obviously be very careful with this command.

To learn more about these commands as well as most commands available through the shell there is the "man" command:

Code:
man rm
man chflags
 
An easy way to delete or move invisible files is to get ahold of "Path Finder" (a finder substitute utility).

It has an option to make all the invisible files/folders visible (can be quickly toggled on and off).

Choose to make everything visible, then manipulate the files you need to work on.
Then, just choose to make normally-invisible files, invisible again.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.