Jorge Gabriel Siqueira Jorge Gabriel Siqueira - 1 month ago 9
Bash Question

Can't follow symbolic links created by other user using root

I've created a symbolic link "foo" using my default user (jgsiqueira) at /tmp/ pointing to a file "bar" located in my home directory:

$ ln -s /home/jgsiqueira/bar /tmp/foo
$ ls -lh /tmp/ | grep foo
lrwxrwxrwx 1 jgsiqueira jgsiqueira 20 Feb 26 12:14 foo -> /home/jgsiqueira/bar


My problem is: I would like to access the content of this file with root through this symbolic link. However, it seems that root it is not allowed to follow this link:

# cat /tmp/foo
cat: /tmp/foo: Permission denied


Can someone help me help me in understand what is going on?

Answer

Interesting. After a quick test on my side, I had the same problem. And after a bit of research I found this. Turns out the problem comes from the /tmp folder itself which restricts the access to symbolic links (put your symbolic link in another folder, you'll see it works).