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

MadHat madhat at unspecific.com
Wed Nov 1 17:54:09 CST 2000


Steve Baker wrote:
> 
> 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.

not according to what you said earlier or from my understanding and what
I know as the definition of a file.  A file is an entry in a directory
that points to an inode, while a symlink is not a file, but just a
pointer to another entry in a directory listing and therefor is not what
I would consider a file (no inode directly corresponding).  But I think
this is getting into semantics.

> 
> 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.

Sorry, I only have experience with *BSD, solaris, Linux, HP/UX and I
don't ever remember seeing any king of "usable" permissions on any of
them.  The technical side may say they exist, but it is useless as you
mentioned earlier because the inode contains the perms and the symlink
does not point to an inode but another file pointer.

> 
> 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.
> 

-- 
MadHat at unspecific.com
                                   "The 3 great virtues of a programmer:
                                      Laziness, Impatience, and Hubris."
                                                 --Larry Wall



More information about the Discuss mailing list