![]() Once you’ve created the sudo user in Ubuntu, you can log in and use the sudo command for administrative tasks.įeel free to contact us or leave a comment if you’ve encountered any issues or have any questions.To invoke a login shell using sudo just use -i. Now, verify sudo access with the whoami command: sudo whoami Next, add the user to the sudo group with the usermod command: usermod -aG sudo username You can confirm that the username exists using the grep command and /etc/passwd file: grep '^username' /etc/passwdĮxample output: :~$ grep '^mruser' /etc/passwd So far, we’ve created a new user and added them to the sudo group, but it’s worth pointing out that you can also add existing users to the sudo group. Adding an Existing User to the sudo Group in Ubuntu You will be asked to enter the password the first time you use sudo access. To use the sudo command, prefix any other command with the sudo: sudo ls -l /root Now that you have created a new sudo user, it’s time to check the sudo access. If the user does have sudo access, then the output of the whoami command will be root.Įxample of me running the command with a newly created sudo user: :~$ sudo whoami If the username has sudo access, then the whoami command will print the word root on the screen. Now, run the whoami command with sudo to confirm the username. To do that, use the su command to switch over to the new user: su username To add a user to the sudo group, run: usermod -aG sudo username Step 4 – Test the sudo User AccessĪfter creating the sudo user, you need to test if the sudo access is working. The syntax to add a user to a group is: usermod -aG To add a user to the sudo group we use the usermod command, which allows you to modify a user’s login information. In Ubuntu and Debian-based systems, members of the sudo group are granted sudo access. ![]() Step 3 – Add The New User to The sudo Group The command will create a home directory and copy multiple configuration files from /etc/skel directory to it. Changing the user information for mruserĮnter the new value, or press ENTER for the default You can just leave the fields blank, and accept defaults by pressing enter (Marked with ⏎ in our example). The output should look like this: New password:Īfter verifying the password, you will be asked a series of questions like full name and phone number. Make sure that the password is strong, and includes both letters and numbers. Replace username with the name of the user you want to create: adduser usernameĪfter adding the user, you will be prompted to create and verify a password for the user. It allows you to modify the configuration settings of a new user. ![]() Log into your server as a root user or another sudo user (if you are using a server to remote machine): ssh Step 2 – Create a New User AccountĬreate a new user to your system via the adduser command.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |