

Replace “bob” with the username you want to add to the sudoers list.Īlso read: For a more comprehensive overview of Add and Remove Users refer to our guide How to Add and Remove Users in Linux Benefits of Adding Users to the sudoers File Benefit.Using the adduser command with the sudo parameter streamlines the procedure by add user to the sudo group and granting them administrative privileges.
#Ubuntu add sudo user password

When prompted, enter a password for the new user and any other information requested.Īfter you finish these steps, the user “bob” will gain sudo capabilities and will be able to run commands with elevated permissions using the sudo command.During the user creation process, this command adds the user “bob” to the sudo group.To add the user “bob” and provide them sudo rights, run the following command:.Log in as root or a user with sudo privileges.To add the user “ bob” directly to the sudoers file, use the adduser command as follows: The -a flag add users to the specified group, and the -G flag specifies the group, which in this case is “sudo.”Īfter running the script, use the groups command to see if the user “bob” was successfully added to the sudo group. To add “bob” to the sudo group, use the following command: sudo usermod -aG sudo bob Using the usermod command, you can add an existing user, such as “bob,” to the sudo group. The user can now log in to the system using their username and password. Once you have completed these steps, the new user account will be created, along with a corresponding group and home directory for that user. Įnter the new value, or press ENTER for the default :~$ sudo adduser bobĪdding new user ‘bob' (1001) with group 'bob'. You can enter the required data, such as a password, complete name, phone number, and other optional entries.Įnter to skip any fields you want to leave empty. This command will question you for additional information about the new user. You may verify the creation of the new user by checking the content of the /home directory or grep on the username in /etc/passwd file.Step3 : To create the new user, execute the following command: sudo adduser bob After confirmation, the user will be created successfully. You may enter the details if you want to, but it is not mandatory. It also asks for details for name, phone numbers, and others. With the adduser command, the home directory for the user is also created. Here's a sample screenshot for the creation of a new user named handbook: You may also use Ctrl+U Linux shortcut to delete the entire line and start from the beginning. When you type your password, it will be invisible, but you can also use delete or backspace whenever you like. You can read the difference between adduser and useradd here. You can either adduser or useradd command for adding a new user. This is to ensure that only people who are having rights over the system or in charge of protecting the system are creating new users and nobody else. To create a user, one must be a sudoer or a root. Note: Adding a new user will also create a user group named the same as the user in Ubuntu. You add it to the sudoer list in the next step. Keep in mind that the user will be a regular user when you create it. If the user that you want to grant sudo access doesn't exist, the first step would be to create that user. Please check the users present on your Linux system. Let’s now get started on creating a sudo user or sudoer in Linux command line. However, I am not sure if all Linux distributions have a group named sudo. The commands used here are standard Linux commands and these should be installed on most Linux distributions by default. I am using Ubuntu in this tutorial, but the steps mentioned here should apply to Debian and many other Linux distributions as well. That was too short, right? Don't worry! I explain the steps in detail. I'll just show how you can add a sudo user to Ubuntu or Debian. In Ubuntu and Debian-based Linux systems, sudo is practically synonymous with root but in reality, sudo is much more than that.īut I am not going to go into details on sudo here. You just add sudo before the command to run it with root privilege. You don't need to know the root password or switch to root user. As a sudo user, you can run commands and access files as root user but with your own password.
