LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-22-2020, 09:39 AM   #1
LegionOfHell
Member
 
Registered: Jul 2020
Posts: 41

Rep: Reputation: Disabled
Which directories should be owned by root?


I Installed Ubuntu base and it boots to #, then I switch to root by doing su - . but I cannot modify any files as root, for instance, when I try to edit and save /etc/hostname , nano complains that it is a read-only filesystem.

I am guessing that during the installation I should have chowned the relevant directories under / like this:

Quote:
chown -R root:root /bin /etc ...
Now there are a bunch of directories under / :

Quote:
bin boot dev etc home lib lib32 lib64 libx32 lost+found media mnt opt proc
root run sbin srv sys tmp usr var
which ones should I set to be owned by root? should I also own the root dir like this:

Quote:
chown root:root /
I also cannot modify any files under /home/user/ when I do su user ... should I do:

Code:
chown -R user:user /home/user/

Or should I just do this:

Quote:
chown -R root:root /
chown -R user:user /home/user
 
Old 10-22-2020, 10:20 AM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Quote:
Originally Posted by LegionOfHell View Post
I Installed Ubuntu base and it boots to #
Since it booted to that prompt, then it already is root.
Quote:
Originally Posted by LegionOfHell View Post
then I switch to root by doing su -
Shouldn't be necessary.

So first advice would be when you boot and it goes to #, type in the command "whoami" and it will tell you. Do that first before you decide any conclusions, instead find it out for real.
Quote:
Originally Posted by LegionOfHell View Post
but I cannot modify any files as root, for instance, when I try to edit and save /etc/hostname , nano complains that it is a read-only filesystem.
Being root doesn't mean you can modify files at any point/situation. Likely /etc/hostname is not write capable, use the command "ls -l /etc/hostname" and it will give you the long listing of the owner, group, and privileges for that file. If you have further questions about that and whether or not the file is truly read-only for root, then please follow-up, but show the outputs of the whoami and ls -l commands suggested please. Otherwise it will be difficult to advise you further.
Quote:
Originally Posted by LegionOfHell View Post
I am guessing that during the installation I should have chowned the relevant directories under / like this:
...
Code:
chown -R user:user /home/user/
Until you understand things further, do not use commands like this, instead you should've installed and left things alone and not tinkered if you don't understand.

For instance to answer your thread question per the title, the directories which should be owned by root are on a clean install. If you tinker with them, not knowing what you're doing, then that changes things and may not be easy to fix. There are some general guidelines but basically those are experience based and the problem is no one can tell what other commands you've used to modify file/directory ownership or privileges. Please try to avoid doing that to your system files in the future.
Quote:
Originally Posted by LegionOfHell View Post
Or should I just do this:
That final question is unclear, but probably relates to the various commands you referred to, and I'd say "Do not do that", whatever it is you're thinking, because honestly those files should have been all set at install and did not need to be changed.
 
1 members found this post helpful.
Old 10-22-2020, 10:44 AM   #3
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Quote:
Originally Posted by LegionOfHell View Post
I Installed Ubuntu base and it boots to #, then I switch to root by doing su - . but I cannot modify any files as root, for instance, when I try to edit and save /etc/hostname , nano complains that it is a read-only filesystem.

I am guessing that during the installation I should have chowned the relevant directories under / like this:


I also cannot modify any files under /home/user/ when I do su user ... should I do:
You shoud NOT modify any ownership permissions on the system. It could break the system and cause a complete reinstall.

From your description it seems you are using su to switch back and forth between user and root. That is not the recommended way to do things. You should always log in as your regular user and only in special circumstances use "su".

You should be able to do
Code:
 sudo nano /etc/hostname
and that should allow editing the file. On Fedora which uses systemd to manage the system I would use
Code:
 sudo hostnamectl set-hostname my.new.hostname
and it would all be done. Use of sudo is the recommended way to execute commands as root without switching to the root environment.

If you are logged in as your regular user you should be able to do almost anything within your home directory, and not modify anything outside that. "pwd" can always tell you what your current directory is. When you su to root then su back to your user it is likely your pwd is not your home directory as expected. Using su to switch back and forth is not a good practice. Using su to root then returning with "exit" is a much better practice as that avoids the confusion of "who am I now?" and "where am I?" -- both of which are easily seen with "whoami" and "pwd".
If you are determined to use su then the problems that develop, such as not being in your users home directory and unable to write there, are of your own making and lack of experience.

What it seems actually happened is that "su -" switched you to root's environment, including his home directory of /root. Then the "su user" switched you to your user BUT did not return you to your home directory (/home/user). Of course your user could not do anything such as writing in /root.

I would recommend doing a lot of studying on system administration before considering something as drastic as a blanket change of ownership on a newly installed system.

Driving a brad into a fine piece of furniture with a sledge hammer is guaranteed to smash the fingers holding the brad as well as destroying the furniture. Your chown suggestion is similar.
 
Old 10-22-2020, 11:01 AM   #4
LegionOfHell
Member
 
Registered: Jul 2020
Posts: 41

Original Poster
Rep: Reputation: Disabled
Here is what happens: https://ibb.co/t4G1m2c

It seems to me that the file system is read-only and not writable...

here is my /etc/fstab:
----
/dev/sda1 /boot vfat defaults,noatime 0 2
/dev/sda2 / ext4 noatime 0 1
----

how do I fix this ?

Last edited by LegionOfHell; 10-22-2020 at 11:10 AM.
 
Old 10-22-2020, 11:09 AM   #5
jmgibson1981
Senior Member
 
Registered: Jun 2015
Location: Tucson, AZ USA
Distribution: Debian
Posts: 1,140

Rep: Reputation: 392Reputation: 392Reputation: 392Reputation: 392
Means exactly what it says. Your filesystem is read only. Whether that is a bad mount, or you already ran some chown -R command and jacked the permissions on the whole system only you know. Generally unless you know what commands do and what you are trying to do you shouldn't run anything outside of your /home/"$USER" directory.

If you did run some global chown command then you should just re-install. There is no fixing that. Linux is very dependent on permissions and there are thousands if not millions of files with specific permissions. You can't fix it in any reasonable time frame.
 
1 members found this post helpful.
Old 10-22-2020, 11:13 AM   #6
LegionOfHell
Member
 
Registered: Jul 2020
Posts: 41

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by jmgibson1981 View Post
Means exactly what it says. Your filesystem is read only. Whether that is a bad mount, or you already ran some chown -R command and jacked the permissions on the whole system only you know. Generally unless you know what commands do and what you are trying to do you shouldn't run anything outside of your /home/"$USER" directory.

If you did run some global chown command then you should just re-install. There is no fixing that. Linux is very dependent on permissions and there are thousands if not millions of files with specific permissions. You can't fix it in any reasonable time frame.
I didn't run any chown commands...

should I add rw to my root partition in /etc/fstab ?
 
Old 10-22-2020, 11:24 AM   #7
jmgibson1981
Senior Member
 
Registered: Jun 2015
Location: Tucson, AZ USA
Distribution: Debian
Posts: 1,140

Rep: Reputation: 392Reputation: 392Reputation: 392Reputation: 392
I'm downloading it right now to see how it works. That being said why Ubuntu Base and not a current ISO? What is your intended goal? Ubuntu Base is not geared toward new users. Also it's max version being 16.04. The current LTS is 20.04. 16.04 will only be supported until April next year give or take.

Last edited by jmgibson1981; 10-22-2020 at 11:25 AM.
 
Old 10-22-2020, 11:31 AM   #8
LegionOfHell
Member
 
Registered: Jul 2020
Posts: 41

Original Poster
Rep: Reputation: Disabled
this is what I used : http://cdimage.ubuntu.com/ubuntu-bas...20.04/release/

there are no disk errors:

Quote:
dmesg --level=err,warn
cat /proc/mounts returns:

Quote:
/dev/sda2 / ext4 ro,relatime 0 0
 
Old 10-22-2020, 11:38 AM   #9
LegionOfHell
Member
 
Registered: Jul 2020
Posts: 41

Original Poster
Rep: Reputation: Disabled
running the following makes the disk writable:

Quote:
mount -o remount,rw /
How to make this permanent ? should I add defaults to my /etc/fstab ?
 
Old 10-22-2020, 12:02 PM   #10
LegionOfHell
Member
 
Registered: Jul 2020
Posts: 41

Original Poster
Rep: Reputation: Disabled
Ok, when I was installing Ubuntu base, I chrooted and then mounted / and /boot..but then I exited without unmounting them...could this be why ?
 
Old 10-22-2020, 12:37 PM   #11
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,836

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
1. how did you install it at all?
2. the root filesystem mounted read only. Usually that means the filesystem is corrupted. You need to check /var/log for details. But probably it (ro flag) was specified in /etc/fstab.
 
Old 10-22-2020, 01:04 PM   #12
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Quote:
Originally Posted by LegionOfHell View Post
running the following makes the disk writable:



How to make this permanent ? should I add defaults to my /etc/fstab ?
But you shouldn't have to do that, it should've been fine when you installed. End of story.

What you're doing now is scrambling to try and get it back to working.

Admirable, but a problem here is based on the changes you've described, you really messed up the system and I'd not recommend trying to unravel this quagmire, and instead re-install.

But, do as you wish, because you were asked to provide the outputs of certain things, and instead you're providing different information.

I think that's about as much help as I'm capable of giving you at this time.

Best of luck.
 
Old 10-22-2020, 01:46 PM   #13
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Quote:
Originally Posted by LegionOfHell View Post
Ok, when I was installing Ubuntu base, I chrooted and then mounted / and /boot..but then I exited without unmounting them...could this be why ?
ANYTHING other than doing the normal install could cause problems.

Since you said this is a new install I would suggest that the best fix for all would be do a complete new install.
There is no reason whatsoever that you needed to do a chroot before mounting because the installer handles all the details and as it finishes it gets everything organized then reboots into the proper configuration with permissions and file structure properly organized. You then log in as your regular user and are good to go from that point.

Try doing a new install, formatting / as it is to be newly installed, I would suggest that you create a separate partition for /home so that you do not lose your data and have to restore from backup when you do another install in the future
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
~/.config/menus - should be owned by root? Robhogg Linux - Security 2 05-09-2009 01:31 PM
All files/Directories owned by root (unable to change with "chown") KinnowGrower Linux - Desktop 8 10-22-2008 10:18 AM
Cannot start connection, /root not owned by root ???!! ALInux Linux - Software 6 12-13-2005 04:50 PM
Make a file owned by root owned by a user sharpie Linux - Newbie 2 02-26-2004 01:26 AM
vfat mount - all files are 'root' owned, but even root can't -WX d33pdream Linux - General 5 02-28-2003 02:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration