Give root privileges to a new user & safely disable the root account on Ubuntu 12.04

For security reasons it’s a good idea create new users with root permissions and disable login access to the default “root” account. This is usually the first thing I do

 Posted April 4, 2016

Log into your server as root.

Create a new user account for yourself.

You’ll be prompted to choose a password and enter user information:

Now let’s give the new user “james” root/sudo permissions. Type ‘visudo’ to edit the /etc/sudoers file:

Find the lines that look like this:

And add your new user underneath, following the same pattern as root:

Save the file:

Press Control-X
Press the letter Y
Hit enter.

Now log out as root, and log in with your new account.

Finally,┬ádisable the root account using the ‘sudo’ command:

Output:
Now any time you need to run something using┬ároot permissions, just prefix those commands with “sudo” using your new user/account:

For example:

You’ll be prompted to enter your password if you haven’t used sudo for a few minutes prior, after which the command will run:

Enjoy!

Leave a Reply

Your email address will not be published. Required fields are marked *