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.

 

Fig 1

 

List Users.

cut --delimiter=: --fields=1 /etc/passwd

Here is the command output.

 

Fig 2

 

Change Password of a User.

Method1:

passwd user-name

Here is the command output.

Fig. 3

 Method2:

Login to new user.

su - user-name

Run the following command.

passwd

Here is the command output.

Fig. 5

 

Add Group.

addgroup group-name

Here is the command output.

Fig. 6

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.

Fig. 7

List all the Users in a single Group.

cat /etc/group | cut --delimiter=: --fields=1,4 | grep group-name

Here is the command output.

Fig. 8

 

Delete User from Group.

deluser user-name group-name

Here is the command output.

Fig. 9

Delete a User.

deluser user-name

Here is the command output.

Fig 10

Delete a Group.

delgroup group-name

Here is the command output.

Fig 11

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

 

Leave a Reply

Your email address will not be published.