[SOLVED] can /root contain files/directories with different owner to root ?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
can /root contain files/directories with different owner to root ?
Hi,
I have came across the /root directory which contains many files and directories with not root owner-ship - owner is in most cases like "normal" user name.
Is it correct ?
Would it be better to change owner in '/root' ,for all files/directories, to root owner ?
Do you have some specific examples to discuss? Hard for me to answer vague hypotheticals...
In general I recommend that you never edit, delete, alter, or change permissions of any file in /root, ever. All the files you need for everyday tasks are located in your /home folder.
Distribution: Slackware (mainly) and then a lot of others...
Posts: 855
Rep:
+1 snowpine.
The user of all the / files is root (assumed) what group will you assign the files to? Some files (esp in /dev) have differnet gropus (eg audio, lp etc).
So do not change anything.
Do you have some specific examples to discuss? Hard for me to answer vague hypotheticals...
In general I recommend that you never edit, delete, alter, or change permissions of any file in /root, ever. All the files you need for everyday tasks are located in your /home folder.
It is too late to satisfy such recommendation. I am doing it quite often :-)
Please, I would like to talk about /root directory.
Last change I did was for /root/.config sub-directory/ies owner:group to root:root 3 days ago.
My question was if it is correct that some directories in /root directory can have different owner:group than root:root and why ?
Yes, it is correct (but can be unsafe). Also nothing bad will happen when you change ownership to root. The /root directory is your - administrator home directory and no other users need to access it. @honeybadger - OP talking about "/root" directory not "/". How it happens? - for example when you copy file owned by other user to this directory, the owner is not changed. Other reasons I don't known. Check that your /root directory has proper permissions (ex. root:root rwx------).
Yes, it is correct (but can be unsafe). Also nothing bad will happen when you change ownership to root. The /root directory is your - administrator home directory and no other users need to access it. @honeybadger - OP talking about "/root" directory not "/". How it happens? - for example when you copy file owned by other user to this directory, the owner is not changed. Other reasons I don't known. Check that your /root directory has proper permissions (ex. root:root rwx------).
Thanks for info.
Example: what's bothering me - I know exactly which directories I have copied to /root manually. But there is a lot of directories created by "normal" application/s and have owner:group as myuser:myuser and/or rwxrwxrwx permission/s.
For example /root/.pki which contains cert9.db , key4.db pkcs11.txt which seems to me like very unsafe.
I have been expecting if some application (started by sudo or under root user (as from terminal as from desktop)) is going to create some directory structure under /root - it should be always root:root rwx------ , but there is too many exceptions
- so I am probably going to to chown root:root for whole /root dir/subdirs.
About rwx------ permission/s I have no idea what is/is not correct.
(just guess - for example /root/.i2p - when I run web browser under "normal user" go to http://localhostort - application probably needs some files with read access permission (to show configurations/status/logs/etc.) - I guess).
Does exist any rules/documentation/info how it should be (what is/is not allowed) or does it depend only on application/developer how file permission/s are managed ?
In general, it is best and common for you to have a separate user, for example named 'myuser', with a home folder /home/myuser/ . 99% of all your activities should be done using this user.
When you need to become root (to administrate your system/install packages, etc. ), you run 'sudo bash' or 'su' .
Answering the original question - it is correct to have files in the /root/ folder owned by another user, in the sense that the kernel does not care, but it is not recomended.
The /root/ folder is best to be kept chmod 700 (drwx------) which means that a program started as an ordinary unix user will not have access to the files in /root/ even if the file in question is in fact owned by the ordinary unix user.
Answering the original question - it is correct to have files in the /root/ folder owned by another user, in the sense that the kernel does not care, but it is not recomended.
The /root/ folder is best to be kept chmod 700 (drwx------) which means that a program started as an ordinary unix user will not have access to the files in /root/ even if the file in question is in fact owned by the ordinary unix user.
Thank you for info.
So, It should be correct and safe and should not create any inconsistencies if I do:
chown root:root -R /root
chmod 700 -R /root
I just want to be sure that I can do it - that's all this question/post is about :-)
From your question I suspect you may not be using the recommended Ubuntu procedure of sudo for terminal commands as root, and gksu for graphical apps as root.
From your question I suspect you may not be using the recommended Ubuntu procedure of sudo for terminal commands as root, and gksu for graphical apps as root.
Sorry, I missed your post #6. Copying a file does not change its permissions. If you are copying file(s) from your user account to root then yes file ownership by the user will be maintained.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.