Open a terminal window and log in to your server via SSH.
Create the user by entering the following command. Replace exampleuser with your desired username:
Set the password for your new user by entering the following command. Replace exampleuser with your desired username:
You will now need to edit your sudoers file to grant your new user the correct permissions. Enter the following command to open your sudoers file for editing:
Type ‘i’ to enter the insert mode, and add an entry for your user below the root user, granting all permissions. Replace exampleuser with your username:
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
exampleuser ALL=(ALL) ALL
Press ‘Esc’ to leave insert mode and enter the following command to save the file and quit visudo:
Log out of your server as the root user by entering the following command:
Log in to your server as the new user by entering the following command. Replace exampleuser with your username, and the example IP address with your server’s IP address:
Now you can administer your server with the new user account instead of root. When you need to execute superuser commands in the future, preface them with sudo. For example, later in this guide you’ll execute sudo iptables -L while logged in with your new account. Nearly all superuser commands can be executed with sudo, and all commands executed with sudo will be logged to /var/log/auth.log.