[NTLUG:Discuss] Is there a way to change permissions of a link

Steve Baker sjbaker1 at airmail.net
Wed Nov 1 18:42:25 CST 2000


MadHat wrote:

> Reread the explanation...
> 
> a sym link is not a file (it does not have permissions), but an entry in
> the directory that point to the file...

Well, to be pedantic, a symlink *is* a file (the contents of which are the name
of the thing it points to) and *does* have permissions - it's just that Linux 
doesn't let you change them - and since it always redirects to the place it
points to, it wouldn't help if you *could* change them.

On SGI's IRIX version of UNIX, you *can* change the permissions of a symlink...
although the kernel still ignores them for any practical purposes.

If you write a program to query the permissions of a file using 'lstat',
you can actually retrieve the permissions of a symlink...they are always 0777
under Linux of course.

In the Linux 'chmod' man page it says:

  "chmod never changes the permissions of symbolic links; the
   chmod system call cannot change their  permissions.   This
   is  not  a problem since the permissions of symbolic links
   are never used.  However, for each symbolic link listed on
   the  command  line,  chmod  changes the permissions of the
   pointed-to file."

...which implies pretty much what I'm saying.

> The file is what has the
> permissions, not the directory entry.  A hard link would have the same
> permissions as the origional file because that is stored in the INODE...

Yes.

-- 
Steve Baker   HomeEmail: <sjbaker1 at airmail.net>
              WorkEmail: <sjbaker at link.com>
              HomePage : http://web2.airmail.net/sjbaker1
              Projects : http://plib.sourceforge.net
                         http://tuxaqfh.sourceforge.net
                         http://tuxkart.sourceforge.net
                         http://prettypoly.sourceforge.net



More information about the Discuss mailing list