- Nikhil Bhaskar
- July 1, 2021
How to create and maintaining system user and group on ubuntu.
In Linux,we can add multiple user & groups on the system.We can manages access control & share information to users.By default, the initial user created by the ubuntu installer is a member of the group which is added to the file /etc/sudoers as an authorized sudo user.
Ubuntu is a multi-user operating system. User can have different permission and some specific access for various command-line and GUI.
Prerequisites
- We can add and remove users, we needs to be logged in as root or user with sudo privileges.
Add User
adduser user-name
Here is the command output.
List Users.
cut --delimiter=: --fields=1 /etc/passwd
Here is the command output.
Change Password of a User.
Method1:
passwd user-name
Here is the command output.
Method2:
Login to new user.
su - user-name
Run the following command.
passwd
Here is the command output.
Add Group.
addgroup group-name
Here is the command output.
List groups.
cut --delimiter=: --fields=1 /etc/group
Add user in a group.
usermod -aG group-name user-name
List Group of a User
Login to user-name.
su - user-name
Run groups command.
groups
Here is the command output.
List all the Users in a single Group.
cat /etc/group | cut --delimiter=: --fields=1,4 | grep group-name
Here is the command output.
Delete User from Group.
deluser user-name group-name
Here is the command output.
Delete a User.
deluser user-name
Here is the command output.
Delete a Group.
delgroup group-name
Here is the command output.
Delete the user’s home directory.
deluser --remove-home user-name
Giving Root Privilege to a User.
Open visudo file that contains the list of sudoers on your system.
vim /etc/sudoers
Add the following lines.
user-name ALL=(ALL) ALL