1

I'm trying to update the ownership of everything in a directory tree from me to root. I'm using find to do it a little more carefully than a recursive chown.

Here are the commands I use to change ownership of all files and directories in my tree:

cd /opt/mydir
# Update files
sudo find . -type f -execdir chown root:root "{}" +
# Update directories
sudo find . -type d -execdir chown root:root "{}" +

These work fine for all files and directories.

But I noticed there are symbolic links in /opt/mydir that point to files somewhere in the same directory tree, that I still retain ownership of.

For example:

lrwxrwxrwx  1 civfan civfan      6 Jul 18  2013 halt -> reboot
-rwxr-xr-x  1 root   root    14832 Jun 25  2013 reboot

This looks wrong and seems likely to cause me permission problems later if I don't fix it now.

How do I change ownership of all symbolic link files, too?

0

The ownership of symbolic links don't matter. Its the referenced entitiy which does.

That said, use find -l to discover symbolic links in a directory tree.

Use chown -h and/or chmod -h to operate on the symbolic link.

find . -type l -exec chown -h root:root {} +
  • Good info about the ownership of the symbolic link not mattering. I deleted my answer that didn't have that info in favor of this. – CivFan Jun 15 '15 at 16:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.