LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   can /root contain files/directories with different owner to root ? (http://www.linuxquestions.org/questions/linux-newbie-8/can-root-contain-files-directories-with-different-owner-to-root-4175416696/)

masuch 07-14-2012 10:50 AM

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 ?

thank you,
M.

snowpine 07-14-2012 11:01 AM

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.

honeybadger 07-14-2012 02:20 PM

+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.

masuch 07-16-2012 05:00 AM

Quote:

Originally Posted by snowpine (Post 4727987)
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 ?

For instance:
.config
.i2p
.emacs.d
.Foxit
.local
.pki !!!???
.TrueCrypt
...
...

eSelix 07-16-2012 05:37 AM

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------).

masuch 07-16-2012 06:55 AM

Quote:

Originally Posted by eSelix (Post 4729323)
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://localhost:port - 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 ?

psyhe 07-16-2012 04:39 PM

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.

masuch 07-17-2012 04:14 PM

Quote:

Originally Posted by psyhe (Post 4729835)
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 :-)

snowpine 07-17-2012 04:42 PM

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.

https://help.ubuntu.com/community/RootSudo
http://www.psychocats.net/ubuntu/graphicalsudo

masuch 07-17-2012 05:41 PM

Quote:

Originally Posted by snowpine (Post 4730968)
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.

https://help.ubuntu.com/community/RootSudo
http://www.psychocats.net/ubuntu/graphicalsudo

Your suspicion is completely incorrect :-)

snowpine 07-17-2012 06:02 PM

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.


All times are GMT -5. The time now is 01:21 AM.