If you want to add a new user account, you can easily control everything via the graphical user interface. For that the command syntax will be: sudo deluser userĭelete user including data from the home directory: sudo deluser -remove-home h2smedia Perhaps later you don’t require some user on your Ubuntu Linux system, in such a case we can delete them even the one you have created. However, this is only possible if the user name to be changed is currently not active (i.e. The username can be easily changed using sudo usermod -l new-username old-usernameįor example: sudo usermod -l myh2s h2smedia For that we can go for the given command syntax: sudo deluser user sudo Well, maybe later you want to revoke or remove the sudo access given to the created or from any existing user. sudo adduser user sudoįor example, here we have a user h2smedia and if we want to provide it sudo rights then the command will be: sudo adduser h2smedia sudo Now, if you also want to give sudo rights to your newly created so that it can execute the command with Admin rights then that is also possible. Whereas to list all available users, we can use: cut -d: -f1 /etc/passwdįor only all normal (non-system etc) users: awk -F'' '' /etc/passwd To List all users on Ubuntu 22.04 or 20.04 In case you missed out on the append option and messed up a user's groups, you can still utilize the output you saw in the second step and add the user to all the groups it belonged to previously.Replace the user with the one you have created in the above command.Ĥ. You just have to verify that things went right.Ĭheck the groups of the user and see if it belongs to the desired groups or not. Step 4: Verify that the user has been added to the new group If things go right, you won't see any output. This is not something you would want in most cases. Without the option -a, you'll remove the user from existing groups and add it only to this new group. Since you are adding it to an additional group, you should use the append mode with option -a: sudo usermod -a -G group_name username 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.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |