How do I make sudo ask for the root password?
Ok, here it is again so you can set the checkmark.
In /etc/sudoers
, add this line:
Defaults rootpw
to turn on the rootpw flag, making sudo ask for the root password.
You need to turn the rootpw
flag on.
I know this question is old, but it is the most concise question I've found for this use case (which is a minor percentage, true, but nonetheless legitimate and helpful in the right scenario).
After putting all the steps together from various sources - including multiple answers to this question, these steps work on Ubuntu-Gnome 16.04 LTS:
- Set a password for root
- This is CRITICAL to do FIRST! (Ubuntu automatically has no password for the ROOT user due to the standard security configuration.
- If you do not do this first, you will lock yourself out from accessing root privileges. This can be overcome by booting in with a Live Disk, mounting the hard drive, and editing the sudoers file, but it's best to avoid that.
- Open a terminal and enter:
sudo passwd
- Set your new password for the ROOT user.
- Change the SUDO configuration to require the root password
- SUDO requires the user requesting root privileges
- Setting the "rootpw" flag instead tells SUDO to require the password for the root user.
- Open a terminal and enter:
sudo visudo
- This will open the "/etc/sudoers" file
- After the other "Defaults" line, add:
Defaults rootpw
- Save it (assuming you are in nano, which is the default, this is CTRL+O)
- Close the file (CTRL+X) & exit the terminal
- You're done!
Just a quick note - I also wanted to make sure that the root user couldn't be used to login from the graphical login, and so was looking into ways to excluded. Apparently, the root user is excluded by default, and cannot be used to login through the Gnome graphical login - which is a very good thing!