ownership in symlinks
Hi, I am having a problem I hope you can help me to solve.
I have a shell script that is run by root, that moves some stuff to another location and leaves at the original place a symbolic link instead.
The problem is that the owner of the link is root, and I would like to have the original user as the owner of the link (so he can follow and access the original file)
Any ideas on how to do that? I looked at ln man pages, but found nothing about ownership
are you going to be running this script for just one user or for a wide array of users?
cos if you are just going to be doing this for one user, then add this to the script:
replacing username with the user, and either replace /path/to/symlink with the path to the link or with whatever variable you are using to hold the symlink's location
chown username /path/to/symlink
I will be running this scritp for all system users, so I don't know how to identify in a shell script the user.group in order to do the chown :(
Ok, I think that the script can get the owner.group info by issuing the following command:
ls -l filename | tr -s ' ' | cut -d ' ' -f 3,4
What do you think? I am not sure if this is totally ok, ls -l filename list the file, tr squeezes all extra spaces between fields, and cut get fields 3 (owner) and 4 (group)