Can I set symbolic link permissions under Linux / UNIX? How can I change symbolic link permissions?
No, you can not. If you try to execute the chmod command on a symbolic link, it will return with an error. Changing ‘filename’ permissions: Operation not allowed. This is quite logical because allowing for a symbolic connection is meaningless. Only the permission for the file referenced is important. In short, the permissions on the symbolic link mean nothing. However, we have some command line option that allows you to set or change symbolic link permissions.
How to change or set permissions on a symbolic link
The chown command line changes the user ID (UID) and group ID (GID) of the given files. Symbolic links named by arguments remain unchanged if -h is not used. Therefore, try the following syntax that affects symbolic links instead of any referenced file. This is only useful on systems that can change the ownership of a symbolic link on GNU / Linux.
chown -h vivek:vivek /path/to/file chown --no-dereference username:groupname /path/to/file
Confirm this with the ls command:
ls -l filename ls -l /path/to/link
Note on the BSD / macOS Unix chown command for the symbolic link
The syntax is as follows:
chown -h user1:group1 filename sudo chown -h www:ftpuser /var/www/html
If the file is a symbolic link, change the user ID and/or group ID of the link itself. You may need to use the sudo command or the su command to change permissions.
You want to know more read the man pages by typing the following command:
man chown man ls