Solution

As mentioned by @[email protected], the solution was to add the flag -H to the chown command. For example, to change the ownership recursively down the file linked by a symbolic link, you would do somehting like

$ chown -HR <symbolic-link>

For reference, see the section on -H:

-H if a command line argument is a symbolic link to a directory, traverse it

Edit 1:

Another useful flag is -L:

-L traverse every symbolic link to a directory encountered

Original Post

On a server I have some folder, x, that contains many files. x has a symbolic link y. y is shared over the network via Samba. Some client creates some files with within the shared y folder (the files are then owned as client:client since I don’t have a forced user configured in samba). I tried to change the ownership of all of those files on the server by doing # chown -R new_user:new_group y, however the ownership of all the files within x stayed the same. I could only change their ownership if I did not chown across the symbolic link.

I thought chown could follow symbolic links?

    • Kalcifer@lemmy.worldOP
      link
      fedilink
      arrow-up
      3
      ·
      edit-2
      1 year ago

      Ah, dang, yeah that would do it. Thank you!

      It appears I have misread the stack exchange posts I was looking at. I thought I read that they said that chown, by default, traverses the symbolic link, but, in actuality, what they were saying was that it, by default, changes the ownership of the target file of the symbolic link.