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.
Im getting confused with my user account and the root account.
When I installed Ubuntu, the installation asked me to provide a username and a password which I now used to login the system.
Now , when I want to switch to root , "su" prompts me for a password that I dont know.
Instead I use "sudo su" and type in my username`s password.
Is this the correct procedure to switch to root user? Please help me...
Im getting confused with my user account and the root account.
When I installed Ubuntu, the installation asked me to provide a username and a password which I now used to login the system.
Now , when I want to switch to root , "su" prompts me for a password that I dont know.
Instead I use "sudo su" and type in my username`s password.
Is this the correct procedure to switch to root user? Please help me...
That's correct. root in Ubuntu (if I remember correct) had a random password generated at install so su won't work, but your user is allowed to sudo commands. To switch to root you could also "sudo -s"
Even after enabling the root account, you will still be prompted for your user password when trying to do admin tasks. You can get used to it, but I solved it by not using the _buntus
Even after enabling the root account, you will still be prompted for your user password when trying to do admin tasks. You can get used to it, but I solved it by not using the _buntus
After giving root a new password with sudo passwd root and enabling local root X login, I logged as root, changed the /etc/sudoers file permissions to read,write by root, added targetpw to the line that begins with Defaults in the /etc/sudoers file, then changed the sudoers file back to read-only. Now the root password has to be given for system administration, not my user password.
With each release, Ubuntu seems to make it harder to use root the way I did in Redhat/Fedora. If they keep it up, I may return to Fedora or start using Debian or Mint.
As you can tell from the previous messages, Ubuntu disables root logins by default, and you are expected to use "sudo" and enter your own password. If you have other users on the system, not using targetpw in sudoers, allows you to give some administrative rights for certain commands without giving up the root password. This does require some work plugging holes, such as entering :!/bin/bash in vim, however if you are the only user, then targetpw is fine.
Many users using Ubuntu come from Windows and have the mind set to want to run as root when they shouldn't be. You probably have seen a number of messages on this site where people get in trouble doing weird things in system directories and then getting into trouble. It should never be necessary to log into an X windows session as root and doing so shouldn't be allowed either. Preventing these things helps protect newbies from themselves.
As you can tell from the previous messages, Ubuntu disables root logins by default, and you are expected to use "sudo" and enter your own password. If you have other users on the system, not using targetpw in sudoers, allows you to give some administrative rights for certain commands without giving up the root password. This does require some work plugging holes, such as entering :!/bin/bash in vim, however if you are the only user, then targetpw is fine.
Many users using Ubuntu come from Windows and have the mind set to want to run as root when they shouldn't be. You probably have seen a number of messages on this site where people get in trouble doing weird things in system directories and then getting into trouble. It should never be necessary to log into an X windows session as root and doing so shouldn't be allowed either. Preventing these things helps protect newbies from themselves.
Then why do both Debian and Redhat/Fedora allow setup of a user generated root password and root login in X?
Because the RH,Debian etc way is the way Unix (eg Solaris HP, AIX etc) works, the Ubuntu approach is non-std, which is more-or-less what some posters have alluded to above.
I prefer the orig Unix way myself as well, but jschiwal's 2nd para explains why Ubuntu did that.
I use Ubuntu all the time in my office desktop and feel that not allowing root login in X is one of the good options Ubuntu has provided. I have seen some of the newbies in the office delete the system file unknowingly from X and then paying the price for it.
And jschiwal has already explained why this option can save systems. And I fully agree with him and I still use Ubuntu and like the option. With some usage you get used to it and dont mind providing password to keep your system safe. Atleast I dont mind it.
Because the RH,Debian etc way is the way Unix (eg Solaris HP, AIX etc) works, the Ubuntu approach is non-std, which is more-or-less what some posters have alluded to above.
I prefer the orig Unix way myself as well, but jschiwal's 2nd para explains why Ubuntu did that.
I prefer the "orig Unix" way of separating the root and user password also. In Ubuntu, anyone knowing the password of the user who installed it can use sudo, give root a new password and lock the user out of their own computer.
I know what Ubuntu was trying to do. I disagree with what I highlighted, in bold, in jschiwal's post. That is his opinion, not a fact and thankfully, the Redhat and Debian communities also disagree.
The so called "Ubuntu way" in regard to root and sudo is starting to remind me more of the "Microsoft way", we'll force you to do it our way.
The only time in the last 2 or 3 years I can remember actually logging in as root was when I logged into a virtual terminal (in run level 3) to run the nvidia install program.
I usually use sudo. If I am in /var/log and looking at a number of root read only logs I might use "su -" instead. Running a command that redirects the output
is easier to do as root than using sudo. This is because the file descriptor is created using the effective uid of the sudo command, which is of the normal user.
There is a related difference between distros in using sudo as well. Fedora core & Ubuntu configure sudo by default to use the user's own password if they are a
member of the wheel group. OpenSUSE configures sudo so that you need to enter the root password. If you have more than one user on your system and you don't want to
give others the root password, then the former method is better IMHO.
I think that most distros seem to be adapting PolicyKit which may reduce the need to use sudo. Especially for common items performed graphically, such as ejecting a CD or DVD or USB device.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.