You are on page 1of 2

Users and Groups Management

PW2: Users and Groups management


Part 1
First and last name: ------------------------------------ Group: -----------------
Objectifs :
✔ Creating users and groups
✔ Managing user account
✔ Managing group membership
✔ Managing the files / directories owner
part 1: Create users and groups
1 Create two groups: Group1 and Group2 (use the command groupadd
group_name)
2 Verify the information about the created groups (use the command cat
/etc/group).
3 What information is displayed?
4 Create the users u1, u2, u3, and u4 (use the command
useradd -m username).
5 Verify the user information (use the command cat /etc/passwd).
6 Recheck the contents of the file /etc/group.
7 What information is displayed?
8 Change the current user to u1.

9 What do you notice?

10 Set the password for the four users u1, u2, u3, and u4 (use the command
sudo passwd u1) (use the same password "linuxtp123" for all).
11 Check that each user has a home directory.
12 Check the identifier of each user as well as the groups they belong to
13 Create a new user u5 with the identifier 1045 (use the command
useradd -m -u 1045 u5).
14 Check that the user has been created with the identifier 1045.
15 Placement of users in their groups:

15.a The u1 and u2 are members of Group1.


15.b U3 and u4 are members of Group2
15.c u2 is also member of Group2.
15.d u2 is also of Group1.

Sudo gpasswd –add u1 group1


Sudo gpasswd –add u2 group1

1
Users and Groups Management

Sudo gpasswd –add u4 group1


Sudo gpasswd –add u2 group2
Sudo gpasswd –add u3 group2
Sudo gpasswd –add u4 group2
Remarque : To modify a user's group to another, you can use the usermod
command. For example: usermod -g group1 u6 -> u6 will be removed from
its primary group and become a member of the group group1). However,
usermod -G group1 u6 -> u6 will be removed from all groups and added to
the group group1.

16 Create a shared directory for each group: /home/group1 and


/home/group2.
Part 2: Change the owner of:
a) The directory /home/u1 « u1 is the owning user, group1 is the
owning group »
b) The directory /home/u2 « u2 is the owning user, group1 is the
owning group »
c) The directory /home/u3 (u3 is the owning user, group2 is the
owning group)
d) The directory /home/u4 (u4 is the owning user, group2 is the
owning group)
a chown u1:group1 /home/u1
b chown u2:group1 /home/u2
c chown u3:group2 /home/u3
d chown u4:group2 /home/u4
e Change the owning group of the directory /home/group1 to
group1.
e.a chgrp Group1 /home/groupe1
f Change the owning group of the directory /home/group2 to
Group2.
f.a chgrp Group2 /home/groupe2
check the result of the these configuration

You might also like