You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

kmosx2: Dealing with Immutable Files

Last modified: Mar 4, 2021 6:43 AM
0 1430 Last modified Mar 4, 2021 6:43 AM
Disclaimer: Apple does not necessarily endorse any suggestions, solutions, or third-party software products that may be mentioned in the topic below. Apple encourages you to first seek a solution at Apple Support. The following links are provided as is, with no guarantee of the effectiveness or reliability of the information. Apple does not guarantee that these links will be maintained or functional at any given time. Use the information below at your own discretion.


Dealing with Immutable Files and Folders

Leopard users please note:
The 'o' flag to ls has become 'O' (capitalised) in 10.5. So everywhere you see ls -aolR … you should substitute ls -aOlR ….


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 - it's 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:<pre>-rwxr-xr-x 1 username staff uchg 0 Sep 17 10:47 filename</pre>
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
sudo chflags -R nouchg /Volumes/*/.Trashes

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:<pre>d--------- 2 root wheel schg 68 Oct 19 2001 ????????????HFS+ Private Data
</pre>
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 FAQs,
kmosx2: Resetting the System Immutable Flag in 10.2and earlier,
kmosx3: Resetting the System Immutable Flag in 10.3, and
kmosx4: Resetting the System Immutable Flag in OS X 10.4.

Do you want to provide feedback on this User Contributed Tip or contribute your own? If you have achieved Level 2 status, visit the User Tips Library Contributions forum for more information.
Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.