LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-23-2004, 11:20 AM   #1
cochoa
LQ Newbie
 
Registered: Nov 2004
Distribution: FC2
Posts: 23

Rep: Reputation: 15
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
 
Old 11-23-2004, 12:00 PM   #2
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994

Rep: Reputation: 76
You need to use chown with the -h option see
Code:
man chown
 
Old 11-24-2004, 03:58 AM   #3
cochoa
LQ Newbie
 
Registered: Nov 2004
Distribution: FC2
Posts: 23

Original Poster
Rep: Reputation: 15
The problem is that this script is run for files belonging to several users, so I have to figure out how can I get the owner.group attribute of such files in order to use chown
 
Old 11-24-2004, 06:59 AM   #4
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 77
why not create a group of users who can run the script, and the group permission to run the script?
 
Old 11-24-2004, 09:17 AM   #5
cochoa
LQ Newbie
 
Registered: Nov 2004
Distribution: FC2
Posts: 23

Original Poster
Rep: Reputation: 15
Mainly because this is a script intended to move stuff to a offline disk. The idea is that users leave in a particular file the path to the files they want to move offline, and then this script runs on a daily basis, and moves those files offline leaving a link to the new location of the file. But then I would need to identify the user.group of each file being moved in order to create the link with the same user.group, unfortunatedly I do not know how to do this from inside the script.
 
Old 11-24-2004, 10:03 AM   #6
cochoa
LQ Newbie
 
Registered: Nov 2004
Distribution: FC2
Posts: 23

Original Poster
Rep: Reputation: 15
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)
 
Old 11-24-2004, 10:05 AM   #7
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,623

Rep: Reputation: Disabled
Code:
ls -la
(That's LS-LA) should show owner and group. Pipe it over to any tool to manipulate output (forgot the comand, sorry) and load the value to $OWNER. Then do a chown...

<edit> Hehe this is simultaneity for you
Glad you knew the comand as well...

Last edited by JZL240I-U; 11-24-2004 at 10:10 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Symlinks and .. smidgie82 Linux - General 2 12-21-2005 05:13 PM
? on symlinks eroica Linux - Software 1 09-21-2004 10:45 AM
symlinks.. NSKL Slackware 3 05-26-2002 06:35 PM
Symlinks b0b0 Linux - General 2 11-08-2001 09:43 AM
symlinks tstuhr Linux - General 3 10-05-2001 11:49 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration