Terminal: Dealing with Immutable Files and Folders

If you have followed all the advice in the Knowledge Base articles “Mac OS X: About Trash, Deleting Locked Files – Article ID:106272” and “Mac OS X: Troubleshooting Permissions Issues” and are still unable to empty the Trash, or move an item to the Trash, you may have an immutable flag set on one of the items. The first thing to do is investigate the problem further.

Finding the Problem File(s) or Folder(s)
Open the Terminal program (from /Applications/Utilities). If an item cannot be moved to the Trash make sure it and the Terminal window are simultaneously visible. Then type:

ls -aolR
followed by a space. Do not press return yet. Then drag the offending file into the Terminal window – its full pathname will appear after your typing. Now press return. Alternatively if the offending item is in the trash you can type:
ls -aolR .Trash
ls -aolR /Volumes/*/.Trashes
where the last line is only necessary if you have additional volumes (partitions or extra hard disks).
For each file and folder you will see a line like:

-rwxr-xr-x 1 username staff uchg 0 Sep 17 10:47 filename

Normal files will have a ‘-‘ in place of ‘uchg’. The ‘uchg’ indicates the ‘User Immutable flag’. This corresponds to the normal Finder lock on the file or folder and can be cleared by the procedures given in the Knowledge Base Articles, particularly 106272.

Alternatively, since you are already in the Terminal, you can type

sudo chflags -R nouchg .Trash
if the item is in the trash. If it is elsewhere, like on the Desktop, just type
sudo chflags -R nouchg
Do not press return yet. Type a space after that text, then drag the offending file/folder into the Terminal window–the system will fill in the full path name. In either case, supply your admin password when prompted – it will not be echoed, just type it and press return. Then quit Terminal and reboot.
If however you see a line like:

d——— 2 root wheel schg 68 Oct 19 2001 ????????????HFS+ Private Data

then the System Immutable flag is set, and you cannot deal with this from the Terminal, even with root privileges. You must instead use single-user mode to change that flag, as described in the accompanying FAQ, Resetting the System Immutable Flag.

http://www.healthsci.utas.edu.au/trsu/help/immutable.html

Related Posts

VirtualBox: VMDK and VDI conversion and resize

Since VirtualBox 4.0 it is possible to resize vdi disk images, that is quit simple using the following command: [crayon-5b4d7ce5ca9a4696298716/] SIZE_IN_MB reflects the new disk size so if you want to increase your image to 25GB, just use: [crayon-5b4d7ce5ca9ac163690792/] Sometimes it happens that you do not use a vdi with VirutalBox, but a VMWare Image […]

Read More

Mac OS X: Ever wanted to integrate your Macs in a Active Directory environment with Two-factor authentication (Part 1)?

Simple AD Integration using knowledge as authentication key, is for some data to protect not enough. So if you want to raise the bar you add ownership (Smartcard, USB Dongle, e.g.) to the knowledge only authentication system. So first stone on your way if you use Snow Leopard, you have to be aware that the […]

Read More

Leave a Reply