1833053 Members
2775 Online
110049 Solutions
New Discussion

Chmod a link file

 
SOLVED
Go to solution
John Ferrara
Frequent Advisor

Chmod a link file

How do I chmod a link file w/o changing the file it's linked to?

lrwxr-xr-x 1 root sys 27 Oct 24 2001 snmpd.conf -> /etc/SnmpAgent.d/snmpd.conf

I want to change the link to 0440.

John
It was working fine when I left....what did you do?
10 REPLIES 10
Pete Randall
Outstanding Contributor

Re: Chmod a link file

John,

Remove the link, set your umask and recreate the link.


Pete

Pete
James R. Ferguson
Acclaimed Contributor
Solution

Re: Chmod a link file

Hi John:

First, the permissions and ownership of a link do not matter.

To change the permissions of the link, remove the link (the entity to which it points is untouched); set the 'umask' you want; and recreate the link.

In the case of a link's ownership, using the '-h' option of 'chown' causes the ownership or group change to apply to the link and not the target.

Regards!

...JRF...
Donny Jekels
Respected Contributor

Re: Chmod a link file

john,

perms on a link is inherrited from the umask of the directory.

those does'nt matter anyway since the linked binary controls the execution rights.

everyone else has giving you the correct method to fix the link perms.

live free or die
donny
"Vision, is the art of seeing the invisible"
Jeff Schussele
Honored Contributor

Re: Chmod a link file

Hi John,

The perms on the link are irrelevant. The destination perms are what count.

Rgds,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
John Ferrara
Frequent Advisor

Re: Chmod a link file

What should the umask setting be to acheive 0440 file?

John
It was working fine when I left....what did you do?
Donny Jekels
Respected Contributor

Re: Chmod a link file

umask 337
"Vision, is the art of seeing the invisible"
Umapathy S
Honored Contributor

Re: Chmod a link file

337

-Umapathy
Arise Awake and Stop NOT till the goal is Reached!
John Ferrara
Frequent Advisor

Re: Chmod a link file

Thanks for all the quick responses. I understand that the perms on the link are irrelevant. However, I run security scans that check for that sort of thing and if I don't correct it I have to explain why to Big Brother.

Thanks,
John
It was working fine when I left....what did you do?
Jeff Schussele
Honored Contributor

Re: Chmod a link file

Hi John,

I certainly feel your pain.
This is one of my pet peeves.
What good are scans if the personnel conducting them have NO clue to the relevance of the output?
You should hold firm on this one & make it VERY clear to mgmnt that in this case they are simply wasting resources. Remind them that EVERY time a link is created or recreated there will be an absolutely unnecessary waste of resources to set link perms. At the least mgmnt should simply ask the scanners WHY they think the link perms are important.

MORAL - Even the best SA can't fix stupid.

Rgds,
Jeff (OK, my rant's over)
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
John Ferrara
Frequent Advisor

Re: Chmod a link file

Jeff,

Thanks for sharing. I would like to share that info w/ mngt. However, I like my job and the low man on the toteum pole doesn't have much of a voice. Besides, if I didn't have all of these security issues to correct, I probably wouldn't have a job here for long ;-)

John
It was working fine when I left....what did you do?