Troubleshooting via Terminal

Because it offers a direct connection to the Unix core of Mac OS X, Terminal can help troubleshoot problems that may not be resolvable on the graphic side of the system.

Help! I Can’t Empty My Trash!

If you happen to have a file stuck in the Trash—say, one that’s locked and you can’t unlock—it can be quite a pain to get rid of. The problem is usually related to permissions ,and Mac OS X doesn’t like you messing with those.

You could, of course, head over to http://www.versiontracker.com to download any of several free tools for fixing the problem (Force Empty Trash, Super Empty Trash, and so on). You could also boot into Mac OS 9, if you have a pre-2003 Mac, and delete the file there.

Thankfully, a much easier alternative lies in the Terminal. Try this command:

 sudo chflags nouchg ~/.Trash/*

The nouchg keyword in the command instructs chflags to turn off the user immutable file flag, thereby unlocking the file. Once you’ve done that, you should be able to delete anything in the Trash through normal means.

Note

If this command doesn’t work, the problem file is not in the Trash on your boot disk. Rather, it was trashed from another drive or disk. In that case, you must remember which disk you trashed the file from, then execute the above command—but within that disk’s Trash folder.

For example, if you have a disk named MyMusic, and that’s where the file in question lives, the command would be sudo chflags nouchg /Volumes/MyMusic/Trash/*.

Finder or Dock Problems ...

Get Mac OS X Power Hound, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.