4

I found the /etc/alternatives/awk file, and when I got a long list of it's details I got:

$ ls -l /etc/alternatives/awk
lrwxrwxrwx 1 root root 13 Jan 22  2017 /etc/alternatives/awk -> /usr/bin/gawk*

So it's a link and has write access to others, so I tried this:

$ echo hi > /etc/alternatives/awk
bash: /etc/alternatives/awk: Permission denied

And then:

$ cp /bin/ls /etc/alternatives/awk
cp: unwritable '/etc/alternatives/awk' (mode 0755, rwxr-xr-x); try anyway? y
cp: cannot create regular file '/etc/alternatives/awk': Permission denied

How is that possible?

I know I'm a normal user, but I have write access to this file!

1 Answers1

8

No, you don't have permissions to write to the file. It's the symbolic link which has rwx-permissions for everyone, but you don't write to the link, you write to the file the link points to.

$ ls -l /etc/alternatives/awk
lrwxrwxrwx 1 root root 13 Apr 28  2018 /etc/alternatives/awk -> /usr/bin/gawk

You can see the link points to /usr/bin/gawk, so look at it's permissions:

$ ls -l /usr/bin/gawk
-rwxr-xr-x 1 root root 658072 Feb 11  2018 /usr/bin/gawk

/user/bin/gawk is owned by root and only root has write permissions, that's why you get Permission denied.

mook765
  • 18,644