Results 1 to 4 of 4
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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 11-23-2004 #1Just Joined!
- Join Date
- Nov 2004
- Posts
- 16
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
Thx
- 11-23-2004 #2
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 locationCode:chown username /path/to/symlink
- 11-24-2004 #3Just Joined!
- Join Date
- Nov 2004
- Posts
- 16
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
- 11-24-2004 #4Just Joined!
- Join Date
- Nov 2004
- Posts
- 16
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)


Reply With Quote
