How to avoid those warnings and error dialogs when copying folder hierarchies in Mac OS X

When copying over large amounts of stuff from one volume to another (e.g., to move your personal data to a new Mac), you will often see two kinds of error dialogs:
  1. "You may need to enter the name and password for an administrator on this computer to change the item named "foo".
  2. "One or more items have special permissions and cannot be copied. Do you want to skip them?"
The first dialog is only a warning, but it, and the subsequent entering of an admin name and password, interrupts the copying process, which is annoying if the copying should happen unsupervised. One reason for it are files that you cannot read. To avoid this, in Terminal, go to the source folder and type

find . -not -perm -00400 -ls
Then, use

chmod u+r filename
on the files that are found. Change it back after copying if the permission is important to you.

The second error is more serious, because some files won't be copied, and you won't know which ones (great UI feedback, thanks Apple!). One reason for it are files that have their setuid or setgid bit set. Use

find . -perm +06000 -ls
to find them, then

chmod u-s,g-s filename
on each file. Then do the copying.

Unless they are executable programs, just leave those bits off, otherwise restore them if you need that functionality. Be aware of the security risk of setuid though: See http://www.osxfaq.com/Tutorials/LearningCenter/AdvancedUnix/ugp2/index.ws for details.

If a file is especially stubborn (not even root can change its ownership or file permissions), it may have its immutable flag "uchg" set - check with

ls -lO (big letter Oh) filename

and remove with

chflags nouchg filename

Then you can change ownership (at least as root) and permissions. Restore it later if needed with

chflags uchg filename

This flag is also set via the "Locked" checkbox in the Get Info window of a file in the Finder, but if the file belongs to root, you cannot change it there unless you're logged into Mac OS X as root (which is usually disabled).


Access Control Lists


Starting with 10.4 (Tiger), Mac OS X also supports Access Control Lists (ACLs). These support finer-grained access control, but can also get in the way of moving data to a new home directory, because they override Unix permissions. A typical effect is that a file or folder will be copied instead of moved, as if you were dragging it over from a different volume. If this occurs, and your Unix file permissions seem fine, check if the file/folder has an ACL attached using

ls -le filename

This lists each Access Control Entry (ACE) in a separate line as a numbered list. You don't usually need ACLs on a local machine. To remove the ACL from a file use

chmod -N filename

You probably want to do this recursively to an entire folder and all its subfolders, like this:

chmod -R -N filename

For more information about ACLs, type "man chmod" into Terminal and search for "ACL", or see David Pogue's "Mac OS X Leopard: The Missing Manual" (the appendix on ACLs is available for free from O'Reilly).

- Jan

We use cookies on our website. Some of them are essential for the operation of the site, while others help us to improve this site and the user experience (tracking cookies). You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.