Executing certain tasks or commands with elevated administrator (root) permissions can be an absolute necessity when managing your own server. However, you may not have access to the root account itself or you may have that type of access limited on your server for security reasons. This is where the sudo command comes in to save the day! By using Sudo you can temporarily grant or escalate root/administrator level privileges to a normal user for a specific task or command. In this article we will cover how to create a sudo user in Ubuntu.
How To Create A User With Sudo Access In Ubuntu
Before we begin you’ll need to login into your server as the root user via SSH. If you’re not certain how to do this please refer to the following guide: Connecting to Your Server via SSH. Once you’re logged into the server via SSH you can grant a user account sudo privileges by utilizing the following steps.
- Enter the visudo command
- Locate the line that looks similar to the following for the root user
- Add the the username of the account that you’d like to grant sudo privileges to below the entry for root
root ALL=(ALL:ALL) ALL new_username_here ALL=(ALL:ALL) ALL
Congratulations the user should now have sudo privileges! If you’d like to add additional users that have sudo privileges, you can add them using the same method referenced above. You can also test to ensure that the user account now has sudo privileges by switching to the user and issuing a command using sudo before the command:
su - username_here sudo ls -alh /root
If the user has sudo privileges you’ll be prompted for the user’s password, followed by a full listing of the root directory after issuing the commands referenced above.
Helpful Related Articles