Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My friend gave me a USB key that has Windows Viruses on it.

On my mac, when I try to delete them it fails and tells me that those files are "locked". I ran an anti-virus, which also was unable to delete them for the same reason.

share|improve this question
I think I found the answer. In the command line I typed "sudo rm filename". – nute May 19 '11 at 8:34
up vote 4 down vote accepted

There are two options for files that came from a Windows drive:

  1. Right click on the file and select "Get Info" (or mark all files and press command + alt + i) to get the file information. There in the "General"-tab you can find and opt-out the "Locked"-option. Trash and delete them.
  2. Open /Applications/Utilities/ and type cd /Volumes/YourDrive, then rm -r thefile.exe. If that fails, try sudo rm -r thefile.exe and enter your password.

Mac has other steps if you can't unlock the file - see this article - TS1402 for details on immutable flags and if the directory permissions won't let you modify a file. The two above steps handle the vast majority of locked files on the mac.

share|improve this answer
I could not uncheck the "locked" option, but the "sudo" worked. Thanks – nute May 21 '11 at 17:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.