Is it possible to change the permissions for the symbolic link?
29,068
While not an exact duplicate, this answer should provide a hint:
$ ls -l
total 0
-rw-r--r-- 1 vidarlo users 0 May 21 19:10 a
lrwxrwxrwx 1 vidarlo users 1 May 21 19:10 b -> a
$ chmod 755 b
$ ls -la
-rwxr-xr-x 1 vidarlo users 0 May 21 19:10 a
lrwxrwxrwx 1 vidarlo users 1 May 21 19:10 b -> a
In short: symlinks does not have permissions. Anyone can read where the symlink points to. The permissions of the target determines the access.
As Rinzwind points out, the -h
flag is for *BSD versions of chmod
. It does not work on GNU versions of chmod
.
Related videos on Youtube
Author by
ph7
Updated on September 18, 2022Comments
-
ph7 over 1 year
I am trying to change the permissions for the symbolic link.
As how you can see in the image, the soft link has 777 permissions, but i would like to change that.
I tried to change that by:
chmod 755 someLink
- but this changes linked directory (someDir) permission.chmod -h 755 someLink
- this brings eroorchmod: invalid option --'h'
Is there a way how to change symbolic link permissions? I am on Ubuntu 18.04
Many thanks in advance
-
Admin almost 5 years-h is freebsd/openbsd so MacOS. Not Linux ;-) freebsd.org/cgi/man.cgi?query=chmod&manpath=SuSE+Linux/… Linux "chmod never changes the permissions of symbolic links; the chmod system call cannot change their permissions. This is not a problem since the permissions of symbolic links are never used. However, for each symbolic link listed on the command line, chmod changes the permissions of the pointed-to file. In contrast, chmod ignores symbolic links encountered during recursive directory traversals." linux.die.net/man/1/chmod
-
Admin almost 5 yearsThanks. Now i got it. How i understand on MacOS you can change the symbolic link permissions, is that right?
-
Admin almost 5 yearsyes more generic: on freebsd/openbsd you can (mac os uses openbsd). Those are UNIX clones so not Linux and UNIX has a couple of features in commands we never got in Linux).
-
Admin almost 5 yearsClear! Thanks @Rinzwind
-
Admin almost 5 yearsRelated (on Unix & Linux): Why do Linux/POSIX have lchown but no lchmod?