Operating System - HP-UX
1832973 Members
2699 Online
110048 Solutions
New Discussion

Re: permissions of a link

 
N.D
Occasional Advisor

permissions of a link

How do I set the permissions of symbolic link
9 REPLIES 9
T G Manikandan
Honored Contributor

Re: permissions of a link

you cannot change the permissions of a link.

You should re-create the link to change its permissions.
Re-create the link as that specific user which you are changing the permissions
Robert-Jan Goossens
Honored Contributor

Re: permissions of a link

Hi,

Normaly you can not change the permissions of a link. Attaching a binary file which can change the permission.

Filename is lchmod.

Hope this helps,
Robert-Jan
G. Vrijhoeven
Honored Contributor

Re: permissions of a link

Hi,

You can not change the rights of a symbolic link,

check the chmod man page:

If chmod is used on a symbolic link, the mode of the file referred to
by the link is changed.

You can do a chown with the -h option.

HTH,

Gideon
Sanjay Kumar Suri
Honored Contributor

Re: permissions of a link

man ln has following to say:

Symbolic links are created with the ownership of the creator and the permissions are of the creator's current umask. Once created, the symbolic link ownership and permissions will not change, since the mode and ownership of the symbolic link is ignored by the system.

If file1 is a file and new_file is a link to an existing file or an existing file with other links, new_file is disassociated from the existing file and links and linked to file1. When ln creates a link to a new or existing file name, ownerships and permissions are always identical to those for the file to which it is linked. If chown, chgrp, or chmod is used to change ownership or permissions of a file
or link, the change applies to the file and all associated links. The last modification time and last access time of the file and all associated links are identical (see chown(1) and chmod(1)).
A rigid mind is very sure, but often wrong. A flexible mind is generally unsure, but often right.
Fabio Ettore
Honored Contributor

Re: permissions of a link

Hi,

as already said you cannot change permissions on link. Then:

# touch pippo
# ll pippo
-rw-r--r-- 1 root sys 0 Apr 6 12:02 pippo
# umask u=rw,g=r,o=r
# ln -s pippo peppe
# ll peppe
lrw-r--r-- 1 root sys 5 Apr 6 12:03 peppe -> pippo

Anyway you can use umask (man umask for more details) in order to change umask on your need.

# umask -S
to see the current setting for umask.

HTH.

Best regards,
Ettore
WISH? IMPROVEMENT!
Bruno Ganino
Honored Contributor

Re: permissions of a link

The permissions of symbolic link are create together creating of link.
After change not possible.
Bruno
Torino (Turin) +2H
A. Clay Stephenson
Acclaimed Contributor

Re: permissions of a link

The permissions of a symbolic CAN be changed; there is an undocumented system call, lchmod, which will do just that.

Here is an attached C source for a program called lchmod.

It will compile with the Bundled C compiler because it is intentionally done in K & R C although you could easily change the syntax to ANSI/C, if you like.

Compile it like this:
cc -o lchmod chmod.c

Use it like this:
lchmod 1755 mylink

Note: This program only understands octal permissions; the task of adding symbolic modes is left as an exercise but the octals work just fine.

If it ain't broke, I can fix that.
Chris Watson
Super Advisor

Re: permissions of a link

For those of us somewhat below the status of guru, can someone elaborate on why you would want to change the permissions of a link, when I understand that the permissions are ignored anyway?

Thanks

CW
Moving along nicely
Michael Tully
Honored Contributor

Re: permissions of a link

Some RDBMS like Informix XPS require symbolic links to raw devices (like linking to say /dev/myvg/rextent1) in which to operate. If the link was created as 'root' instead of the owner being informix it won't work. So in this instance, it is not ignored. The program would be useful if there are quite a number of sym links that need the ownership changed or are in use. If only a couple and not being used, then remove them and start over as the required user.
Anyone for a Mutiny ?