There have been multiple accounts created with the sole purpose of posting advertisement posts or replies containing unsolicited advertising.

Accounts which solely post advertisements, or persistently post them may be terminated.

Can you recursively chown all files in the folder linked by a symbolic link?

Solution

As mentioned by @deong, 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

<pre style="background-color:#ffffff;">
<span style="color:#323232;">$ chown -HR <symbolic-link>
</span>

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?

deong ,

I’m not in front of a computer to test, but the man page would suggest that chown -HR would do the trick.

Kalcifer OP , (edited )

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.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • [email protected]
  • random
  • lifeLocal
  • goranko
  • All magazines