Linux - SoftwareThis 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
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.
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:
Since it booted to that prompt, then it already is root.
Quote:
Originally Posted by LegionOfHell
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
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
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
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.
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.
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.
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 ?
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.
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.
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.
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.