Re: Behaviour of chmod/chown on symlinks

Peter Benie (
Tue, 9 Sep 1997 16:43:20 +0100

Keith Owens writes ("Behaviour of chmod/chown on symlinks"):
> The man/texinfo page for chown implies that chown should change the
> target unless the -f flag (do not dereference) flag is set. However
> chown *always* changes the link instead of the target. Is this the
> desired behaviour?

That's an error on the info-page. It should read '-h':
bash:~$ chown -h user filename
chown: --no-dereference (-h) is not supported on this system

There are two common behavours for chown().

1) Chown never follows symlinks (eg. Linux), or
2) Chown always follows symlinks and lchown never does (eg. Solaris).
(cf stat, lstat)

GNU's chown program does whatever the underlying libc function does
(which typically reflects what system calls are provided), so it
behaves differently depending on which flavour Unix you are using.

Personally I prefer Linux's for the chown program since it prevent
chown disasters where the sysadmin runs 'chown -R user .' instead of
'chown -hR user .' thus changing the ownership of system programs. I
don't see the need to switch to lchown since it doesn't gain you

Linux's behaviour is well established and changing would result in
everybody's configure scripts breaking.