Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    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


  2. #2
    Linux Guru lakerdonald's Avatar
    Join Date
    Jun 2004
    St. Petersburg, FL
    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:
    chown username /path/to/symlink
    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

  3. #3
    I will be running this scritp for all system users, so I don't know how to identify in a shell script the in order to do the chown

  4. $spacer_open
  5. #4
    Ok, I think that the script can get the 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)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts