Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

How do I change the owner:group of a symlink?

by v_thunder (Scribe)
on May 24, 2002 at 03:38 UTC ( #168970=perlquestion: print w/replies, xml ) Need Help??
v_thunder has asked for the wisdom of the Perl Monks concerning the following question:

I am testing this on HP-UX 11.00 on PA-RISC.

The perl chown command is following links when the last argument is a symbolic link and not a normal file. I'd like to change the ownership of the link itself.

Just for completeness: GNU chown sets the owner:group of the link itself. HP-UX's chown behaves as perl does.

SoPWified - dvergin 2002-05-24

  • Comment on How do I change the owner:group of a symlink?

Replies are listed 'Best First'.
Re: How do I change the owner:group of a symlink?
by Marza (Vicar) on May 24, 2002 at 19:58 UTC

    Actually you can't in Perl.

    As Tom Christiansen has said(I don't remember where):

    "Perl doesn't do this. Do you know why many systems don't support the idea? Because it conveys no distict functionality. Modes and owners and times on symbolic links have no meaning. So why bother? And it's very non-portable."

    Now as to making a system call. Did you use the "-h" option? I did and it did change the link's ownership without changing the file.

      Oh, bummer. I know it doesn't really matter, but I just need this group of to be owned by bin:bin. Just, uh, because :)

      And you are absolutely right about the -h option. I don't know how I missed it, it's the first option on HP-UX's chown(1) manpage!

      Thanks a bunch,

Re: How do I change the owner:group of a symlink?
by Anonymous Monk on Jun 13, 2017 at 14:16 UTC
    use Lchown; lchown $uid, $gid, @linknames or die "Can't 'lchown($uid, $gid, @linknames)': $!";

    See Lchown for details.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://168970]
Approved by mdillon
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (3)
As of 2017-11-25 07:58 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (355 votes). Check out past polls.