Tuesday, February 2, 2010

Chown and symlinks

Had a persistent problem with an rsync backup job trying to set file attributes on some symlink files, and failing, as it did not own the files. But I'd done a chown -R to recursively set ownsership on every file in that directory. Anyway, it turns out that chown operates on the target of the link, not the link itself, unless you use -h


chown -h username:usergroup some_symlink_file


Or, for bonus points:

find . -type l -exec chown -h foo:bar {} \;

No comments:

Post a Comment