Score:0

Creating a user with root reading access, but only can write its own files

cn flag

I need to create a user that can read files in system like root user, but can only write like a normal user.

How can it be done?

Thanks in advance.

vidarlo avatar
om flag
What are you attempting to achieve? This sounds like an [X-Y problem](https://xyproblem.info/).
james hofer avatar
cn flag
@vidarlo The user can read any file in the system. But can only write files in /home/[user] which belongs to it. How can I give such permissions to a user?
vidarlo avatar
om flag
What is your end goal? What are you attempting to achieve?
james hofer avatar
cn flag
@vidarlo I need to run my app in some servers. The app must not be ran as root. So a user is needed with those permissions. It needs to read any file but only can write for its own.
vidarlo avatar
om flag
What does your app do? Which files does it need to read? Why? This still sounds like X-Y problem...
sudodus avatar
jp flag
What you need, that a normal user without sudo privileges cannot do? Details please.
james hofer avatar
cn flag
@sudodus My app needs to be run by a specific user that described. Not a privileged user. It's a server app, so it needs security. I can't let it change any file in the system. But it needs to read any file because it works with file inputs in some parts.
sudodus avatar
jp flag
There is no problem for 'a normal user without sudo privileges' to read most files. But there are some directories and files, that for security reasons have read permissions only for 'root', and those cannot be read by 'a normal user without sudo privileges'. I don't see any way to make a user that can read them without modifying the read permissions for those secret files, and I think it is a bad idea to make such modifications.
Score:1
vn flag

You can't easily do this. The Unix/Linux permission model is based on "Owner/Group/Others" permissions.

Most files are readable by everyone by default. And applications (or components) that should read root exclusive files must be run as root.

Everybody has managed to use this system for many decades, so your application should be able to as well.

james hofer avatar
cn flag
Thanks for the answer. My app needs to be run by a specific user that described. Not a privileged user. It's a server app, so it needs security. I can't let it change any file in the system. But it needs to read any file because it works with file inputs in some parts.
Artur Meinild avatar
vn flag
Ok please tell: Which specific files, which are not already readable by anyone, does it need to read?
james hofer avatar
cn flag
Sorry for the delay. Ok to be clear, you say a normal user can read all files in the system (even with different owners) except only specific files?
Artur Meinild avatar
vn flag
Yes mostly. Very few files a read-only by root. You can see it on the permissions.
james hofer avatar
cn flag
Thanks my friend. I already upvoted your answer.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.