S
S
Sergei Abramov2020-12-11 19:29:57
linux
Sergei Abramov, 2020-12-11 19:29:57

How to set access rights to a symlink?

There is a file that lies in /etc/vendorname/file.txt - which is periodically regenerated, with owner root:root. Can I somehow make a symlink to it for a non-root user of the system, so that it would be available to him?
I tried this as a user:

sudo ln -s /etc/vendorname/file.txt ./file.txt
sudo chown -h user:user ./file.txt
cat file.txt
cat: file.txt: Permission denied

Answer the question

In order to leave comments, you need to log in

3 answer(s)
F
FirststepsRu, 2020-12-11
@PatriotSY

What's the difference who owns the file, it's important what level of access to it. Most likely, the /etc/vendorname folder or the file itself is closed for reading (for example, chmod 700 or 600)
In order for everyone to read this file, you need to do it from under root (from under the user user there will not be enough privileges)
chmod a+r /etc/ vendorname
chmod a+r /etc/vendorname/file.txt
Then the user will be able to make a symlink. If you cannot allow everyone to see this file, then you need to add the user user to the root group. And allow the group to read this file via g + r. If this file is regenerated, then it is possible that the privileges will be lost every time, and the program that creates this file will need to be changed.

B
BorLaze, 2020-12-11
@BorLaze

And what's the problem with giving read permissions to /etc/vendorname/file.txt? Like rw-r--r--?

K
ky0, 2020-12-11
@ky0

You can give the user permission to interact with this particular file using sudo.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question