How can I help

Stay informed and learn

Let's connect

How to change symbolic link permissions on Linux?

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.

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

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

You can also see the Linux version of the chown command instructions here, and BSD/Unix version of chown here online on the FreeBSD project.

Newer post

How to add SWAP space on Ubuntu/Debian Linux server?

Older post

How to configure Git to remember username and password in a repository?

comments powered by Disqus

Looking for an IT professional?

Book a call Email me