ubuntu-10-logoAdding a new sudo super powered user account to your Ubuntu Server is pretty simple, and more as a note to myself than anything else, here are the steps to do it.

[IMPORTANT: This has the potential to seriously damage your system if it goes wrong – mucking up the sudo command had grave consequences for any linux distro. Try it out in a test environment first if you can!]

First, add the new user account through the use of the useradd command. Note the added switches which create the user’s home directory in the specified location.

sudo useradd -d /home/newuseraccount -m newuseraccount

With the user created, next set his password using:

sudo passwd newuseraccount

(I like bash as my default shell, so you can follow these steps to do this if needed).

Now the fun part. While we can make use of the visudo command to directly edit the sudoers file (in the past this was the only way to do it), nowadays it is advised to rather make custom changes in an extra file, basically meaning that you can now easily upgrade your system without losing all of your carefully crafted user accounts. To do this, create a file in the /etc/sudoers.d directory and edit it.

sudo touch /etc/sudoers.d/sudo-custom
sudo chmod 0440 /etc/sudoers.d/sudo-custom
sudo nano /etc/sudoers.d/sudo-custom

Append the following line to add your new user account to the list of sudo accounts:

newuseraccount ALL=(ALL:ALL) ALL

Note we’ve gone and created a really powerful sudo account with the declaration above. You might want to temper it a bit by reading up on the various options available to you.