I have a issue: I need to change the permission of the symlink from 777 to 755 and I do not have any idea how should I do it. I have tried using the chmod
command but it's not working.
I want
lrwxrwxrwx 1 frosu 2016_cluj 5 Jul 4 13:53 test6 -> test0
to
lrwxr-xr-x 1 frosu 2016_cluj 5 Jul 4 13:53 test6 -> test0
Best Answer
Some systems support changing the permission of a symbolic link, others do not.
-h
)Since the feature differs, POSIX does not mention the possibility.
From comments, someone suggests that a recent change to GNU coreutils provides the
-h
option. At the moment, that does not appear in the source-code for chmod:and
long_options
has this:Permissions are set with
chmod
. Ownership is set withchown
. GNU coreutils (like BSD) supports the ability to change a symbolic link's ownership. This is a different feature, since the ownership of a symbolic link is related to whether one can modify the contents of the link (and point it to a different target). Again, this started as a BSD feature (OSX, FreeBSD, etc), which is also supported with Linux (and Solaris, etc). POSIX says of this feature:So much for the command-line tools (and shell scripts). However, you could write your own utility, using a feature of POSIX which is not mentioned in the discussion of the
chmod
utility:The latter function adds a flag parameter, which is described thus:
That is, the purpose of
fchmodat
is to provide the feature you asked about. But the command-linechmod
utility is documented (so far) only in terms ofchmod
(without this feature).fchmodat
, by the way, appears to have started as a poorly-documented feature of Solaris which was adopted by the Red Hat and GNU developers ten years ago, and suggested by them for standardization:According to The Linux Programming Interface, since 2.6.16, Linux supports
AT_SYMLINK_NOFOLLOW
in these calls:faccessat
,fchownat
,fstatat
,utimensat
, andlinkat
was implemented in 2.6.18 (both rather "old": 2006, according to OSNews).Whether the feature is useful to you, or not, depends on the systems that you are using.