Hi I have Ubuntu Server 14.04.2 LTS installed and when I use sudo with my regular username it requests my username password instead of the root password. Is this normal? If not, how do I set it up to ask for the root password?
2 Answers
That is normal. User which you are logged in as is in the group sudoer
.
Also, if you want, you can create root
user - but it is not recommended. That will make a known target for crackers to attack your system.
Enabling
To actually enable root
logins first you have to set a password for the root
account and then unlock the locked root
account. If you don't set a password for the root
account the passwd
command will return
passwd: unlocking the password would result in a passwordless account.
So, first execute in a terminal
sudo passwd root
you will prompted for a new Unix password. Write it twice(second for confirmation).
Then execute
sudo passwd -u root
to unlock the account. This should return
passwd: password expiry information changed
-
Thanks for the info. But then what is the point of root if I can create a user and just use sudo? I thought the point of root was to allow the final permission. But executing sudo with just a regular username and password defeats that purpose. @2707974 Apr 2, 2015 at 7:53
-
1The risk with using root is that any action you trigger (or occurs while you are root) will run as root (with unlimited privileges). Whereas, with sudo only commands you want will run as root (level of privilege). This ('sudo') is a mature implementation of least privilege, complete with logging, and is much safer than using root.– david6Apr 2, 2015 at 8:58
-
The command
sudo
let you decide which users can run what commands. And it let you do that without knowing the other users passwords. Sharing password is a absolutely no when it comes to security. You plainly doesn't do that, no excuses. And withsudo
you even can run commands as a locked user that can't log in. That makes the bar of cracking the system much higher. So, don't run as root user. Don't surf as root user. Lock down root user as much as you can. Only use root user when you must, not when it is convenient. We don't want the Microsoft way in Linux.– AndersApr 3, 2015 at 12:40 -
1You need to be a member of sudoers to be allowed to run sudo, and you are limited to using only the functions which sudoers allows you to use (for full administrative users, everything; but you can give a user only some of the privileges, and they can use sudo for only those operations). If a normal unprivileged user tries to use sudo to perform a task that requires privileges, they'll get a permissions error. Apr 3, 2015 at 13:36
-
And, you can track use of the root. It also gives you traceability. Locking root user will also lock a possible known account on your computer, which make it harder to crack your computer.– AndersApr 7, 2015 at 0:26
I suggest NOT to activate root.
If you need a terminal as root, open up a terminal and type
sudo -i
then you will get a root terminal if neede.
Else stick with what david6 suggested, only execute your specific command as root.
This is best practice nowadays.
sudo
is supposed to do. Read theman
page for more information.