Is booting into recovery console to gain root access to "sudoers" file the proper way to enable "sudo" for myself on a clean Ubuntu 14.04 LTS installation? If yes, how do I do it? If no, what is the best way?
2 Answers
Most people who install Ubuntu will already have an account, with sudo privileges, set up automatically. This will be the case if you install from the official desktop installer. If you install from a text-mode installer such as a server installer, then it's achieved by setting up a user account for yourself, and leaving the root password field blank. This will make it set your account up with sudo privileges.
If you gave a root password during installation and you want to instead use sudo, then there are a few steps:
Give your account sudo access
Log into the root account (eg with
su)Make sure sudo is installed with
apt-get install sudoAdd your user to sudo with
adduser username sudowhere "username" is the account name to add to sudo.Log out fully from your account then log in fresh.
Remove root password
First, make sure you can sudo from your account.
Then disable logging in as root with
sudo passwd -l root
- 37,804
If you're using the default user (the one created at installation) then they're already in the sudoers file, and can edit the file by running the command:
sudo visudo
This will prompt you for the default user's password, then allow you to edit the file.
- 20,241