0

I'm starting in programming with multiple exercices and I don't know how to change my link permission (lrwxrwxrwx to lrwxr-xr-x).

I have already searched solutions from Google and Youtube but nothing happen when I try their solutions. Can someone help?


ok my bad my adblock was on.

My problem is the last line with " test6 -> test0 "

My result The requested result

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
Raph
  • 1
  • IMHO you can't . You can change them on source file/directory – Romeo Ninov Sep 06 '22 at 19:40
  • 1
    The link permissions are not really used. Permissions set on the file the symlink points to will be used to restrict access. What are you trying to accomplish with a chmod of the symlink perms? – doneal24 Sep 06 '22 at 19:40
  • 1
    You can change only the linked file permission, symlinks will be always lrwxrwxrwx which doesn't mean everybody has full permission on the file. – gabor.zed Sep 06 '22 at 19:41
  • I have to reproduce this results (LRWXR-XR-X), knowing that I have no starting point, where can i put a photo to show you ? – Raph Sep 06 '22 at 19:48
  • @Raph, edit your answer and click on the icon like small photo. – Romeo Ninov Sep 06 '22 at 19:51
  • I would like to but I don't have the icon – Raph Sep 06 '22 at 19:54
  • Raph, when you started the exercises were you advised to use a particular system? What you want is not possible under Linux, but is possible with something like OpenBSD – Chris Davies Sep 06 '22 at 21:28

2 Answers2

2

If you have not already done so, reinstall the system with OpenBSD, and then you may use chmod -h to change the permissions of the link:

$ touch foo
$ ln -s foo bar
$ stat -f '%p %N' foo bar
100644 foo
120755 bar
$ chmod -h 700 bar
$ stat -f '%p %N' foo bar
100644 foo
120700 bar

Otherwise, if you are on an operating system that does not support the above, you are out of luck. For example, chmod(1) on a Linux may contain something along the lines of:

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.

thrig
  • 34,938
-1

to assign "LRWXR-XR-X" permissions you can use the command (on the directory with the file):

chmod test6 755

July
  • 1
  • This changes the permissions on the file test0. Permissions on the symlink test6 are unchanged. The OP asked how to change the perms on the symlink itself. – doneal24 Sep 06 '22 at 20:25
  • I see, sorry I didn't get that part, as far as I know symlinks behave like the actual file, so it should have the same permissions. – July Sep 06 '22 at 20:46
  • It's always worth testing a solution before posting it. – Chris Davies Sep 06 '22 at 21:13
  • The symlink just needs to have more permissive settings than the target. 0777 is the most permissive so that is what the symlink is set at. Access to the target is ultimately determined by the target's permissions. – doneal24 Sep 06 '22 at 23:26