Do I have to chmod after ln -s?

4

After I create a symlink with 'ln -s' (in Ubuntu 12.04, as root), it seems to be created with 777 permissions. Is that normal? Should I always do 'chmod 644' after doing 'ln -s'?

ChocoDeveloper

Posted 2012-07-30T21:09:16.683

Reputation: 2 327

Answers

2

The permissions shown for symlinks (usually 777) are entirely irrelevant. They're fictional (something has to get displayed) and unchangeable. Any attempt to modify them (e.g., with chmod) would actually modify the permissions of the original file, not the symlink.

A symlink isn't a normal file: You can't read it, you can't write to it and you can't execute it. In a certain sense, symlinks inherit the permissions of the original file.

The only way to modify a symlink is to move (rename) or delete it, but moving or deleting a file requires permissions on the directory, not the file itself.

Dennis

Posted 2012-07-30T21:09:16.683

Reputation: 42 934