So, you'll be modifying the user's properties and adding it to an additional group. If it runs successfully, you should see an output like this: adduser abhi adminĪlternatively, you can use the usermod command. Step 3: Add user to the groupįor this, I recommend using the adduser command on Ubuntu: sudo adduser username groupname Now, you have the user name and the group information. If the group doesn't exist, you can create a new group like this: sudo groupadd new_group_name The output is several lines long, by the way. You can see all the groups and get the exact group name from the output. If needed, you can see all the user groups present on your Ubuntu system: getent group That's the Ubuntu way of creating the primary group with the same name as the user name. As you can see the user abhi belongs to the group abhi. Step 2: Get the groups detailsįirst, check the groups the user belongs to: groups username Once you know the user name, it's time to find the details about the group. I'll be changing the group of the user abhi and add it to sudoer list by adding it to the sudo group. Normally, the regular users (non-system users) are at the bottom of the long output of the compgen command: compgen -u If you are not sure of the exact username, you can list all the users on your Ubuntu system. Verify that the user has been added to the group.List the group it belongs to and the group you want to add it to.Get the exact user name you are modifying and adding to a group.The entire process consists of the following steps: You won't always have all the details at hand and you may have to search for them. Steps for adding a user account to a groupĪs a sysadmin, you might need to know a few details before you add a user to a group. I'll go over the following in this tutorial: But if you are new to it, let's see the steps for adding a user to a group in a bit more detail. That was quick and simple if you are a seasoned Linux user. Quickly verify if the user was correctly added to the desired group by checking its groups: groups user_name Without the -a option, you'll overwrite the group settings and the user will belong to only the specified new group which could be catastrophic. It stands for 'append' and this way you add the user to a new group while keeping it in other groups as well. See you next Friday in DevOpsFriday series.That -a option is crucial here. I'd love to connect with you at Twitter | LinkedIn | GitHub Yay □ we were able to create a new user on our machine. When you use sudo for the first time in a session, you'll be requested for that user's password. Now run any command to test, for example. Switch to the new account and Test sudo access sudo softĬheck that you can use sudo as a new user by appending sudo to the command you want to run with superuser privileges. All members of the sudo group have full sudo rights by default on Ubuntu. To add the user to the sudo group, execute the usermod command, replacing soft with the username you just added. Enter the new value, or press ENTER for the default Full Name : Idris Accepting the defaults and leaving all of this information blank is fine, but you can also set them. Īfter that, you'll be prompted to enter some details about the new user. Īdding new user `soft ' (1002) with group `soft'. You will be prompted to enter a new password and retype the new password. You may add sudo if you are not logged in with the root user account. Use the adduser command to add a new user to your system: #adduser soft Login / ssh into your server ssh root this command if you are already logged in to the server to switch to the root user. This post will show you how to create a new sudo user on Ubuntu 18.04 or 20.04.2.0 without having to change the /etc/sudoers file on your server.įollow the steps below to achieve the expected result 1. The sudo command allows regular users to gain administrator rights that are usually only available to the root user. It's already Friday, and I'm delighted □ to see you here.Īnother day of problem-solving, so we'll see how it goes.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |