Linux-for-Sys-Ads/C2/Administrating-Group-with-gpasswd-command/English-timed

From Script | Spoken-Tutorial
Jump to: navigation, search
Time Narration
00:01 Hello and welcome to the spoken tutorial on Administering Group with gpasswd command.
00:09 In this tutorial we will learn to
00:12 Set group administrator
00:15 Set group member
00:18 Add and delete user
00:21 Remove password of a group
00:24 Restrict access of a group
00:27 We will do this through some examples.
00:31 To record this tutorial, I am using Ubuntu Linux 16.04 OS
00:38 To practice this tutorial,

you should have gone through the Linux System Administration tutorials on this website and

00:47 you must have root access to your computer.
00:52 We already know that we can use gpasswd command to set the password for a group.
00:59 It can also be used to add members, delete members, give administrative rights, etc.
01:07 This is the syntax
01:10 Here the option field is not mandatory.
01:14 For this demonstration, we will first create a group named biotech.
01:20 Open the Terminal by pressing Ctrl, Alt and T keys simultaneously on the keyboard.
01:28 Now login as superuser or root user.
01:34 Here onwards, please remember to press the Enter key after typing each command.
01:41 Let us create a group biotech
01:46 The group biotech is added with GID 1011
01:52 Now, let us secure this group’s access with a password.
01:57 Type gpasswd space biotech
02:02 Then I will type the new password as pass_biotech
02:08 Retype the same password
02:12 We will now add five new users to the system using adduser command.
02:18 Pause the video here and create some users with the following details:
02:24 For this demonstration I have already done this.
02:28 Now let us check the /etc/passwd file.
02:34 We have got five new users abhishek, ashok, anushka, asha and anshu.
02:42 Every group can have administrators and members.
02:47 Now, who is the administrator of a group?
02:51 Administrator is the one who can add and remove users from that group.
02:57 Administrator can also change the password of the group
03:02 There can be more than one administrator for a group
03:07 Who is a member of a group?
03:10 Members can access the group without being prompted for a password.
03:16 We specify administrators and members as list of usernames.
03:22 Let us see some examples.
03:25 As a system administrator, you can use -A option, to add one or more group administrators
03:34 -M option is to add one or more group members
03:40 You can use both -A and -M options together in a single command.
03:47 Switch to the terminal,
03:50 Type the command as shown.
03:53 Note that we should not leave any space before or after the comma.
04:00 This command will add anshu, ashok and abhishek as member of the group biotech.
04:08 And user abhishek will be the group administrator.
04:13 Let us now check the /etc/gshadow file for the entry of group biotech .
04:21 Type the command as shown.
04:25 Notice that anshu, ashok and abhishek are listed as members of the group biotech.
04:34 And abhishek is the group administrator.
04:38 Now, let me try to add user anshu as an another administrator.
04:44 Type the command as shown
04:48 Again check the entry for the group biotech in gshadow file.
04:54 Notice that now only anshu is the administrator, and abhsihek is not.
05:00 What is the reason for this?

gpasswd command with hyphen A option removes the existing administrators and replaces with the new ones.

05:13 Let’s now learn to set abhishek and anshu as administrators for the group biotech.
05:21 So type the command as shown.
05:25 Make sure that there is no space between the comma and username.
05:31 Once again check the entry for the group biotech in gshadow file.
05:36 This time we see that both anshu and abhishek are administrators.
05:42 So then, how can we add a user to a group without replacing the existing member list?
05:49 We have hyphen small a option for this purpose.
05:54 A user can be added to a group by a super user or a group administrator.
06:01 Let me try to do this with the group administrator login.
06:07 We will open a new terminal for this.
06:11 Right click on the terminal.

And select Open Terminal from the pop-up

06:17 From this point onwards, we will use these two terminals.
06:21 We will switch from one terminal to another for demonstration purpose.
06:26 In the new terminal, note that we are logged in as user spoken.
06:32 Let me now login as user abhishek.
06:37 To add user asha to the group biotech, type the command as shown
06:43 The option -a can be used to only add one user at a time.
06:51 The output says user asha is added to the group biotech.
06:57 Switch to the terminal where we are logged in as a root user.
07:03 Now check the entry for the group biotech in gshadow file.
07:09 Notice that, asha is added as a member of the group biotech.
07:15 We will check the details of user asha using the id command.
07:21 Group biotech is listed as a supplementary group for user asha.
07:27 How can we remove a user from a group?
07:30 You can use the -d option for this purpose.
07:35 This option can be used to delete one user at a time.
07:40 Both super user or group administrator can remove a user from the group.
07:47 Switch to the terminal where we are logged in as user abhishek.
07:53 Now to delete user asha from the group biotech, type the command as shown
08:01 The output says that the user asha has been removed from the group biotech.
08:06 Exit from the user account abhishek.
08:10 Now, switch to the terminal where we are logged in as a root user.
08:16 Check the entry for the group biotech in the gshadow file.
08:22 Notice that user asha is no longer a member of the group biotech.
08:29 Let’s see what happens if we remove the password for the group?
08:34 We have to use hyphen small r option for this.
08:39 In the terminal, type gpasswd space -r space biotech
08:48 Now check the entry for the group biotech in the gshadow file.
08:54 Notice that the password is empty.
08:58 We can see the users who are already listed as members of this group.
09:04 Only the members are allowed to issue newgrp command to join this group.
09:11 Any non-member, for example asha, cannot join the group anymore.

Let us verify this.

09:19 Switch to the second terminal.
09:22 Now login as user ashok, who is a member of the group biotech.
09:29 Then login to the group biotech.
09:33 We didn’t get any error.
09:36 Now type the id command.
09:39 The output shows that we are logged in to the group biotech.
09:44 So, a member can login to a group, even if the group does not have any password.
09:51 Exit from the group biotech.
09:54 Now logout from the user account ashok.
09:58 Let us now try to login as user asha who is not a member of the group biotech.
10:06 Now let me try to login to the group biotech .
10:10 It is asking for a password.

As the group biotech doesn't have any password, we can’t proceed further.

10:18 Press Enter to exit from the group login process.
10:23 So, we understand that a group need not have any password.
10:28 But in that case, a non-member will not be allowed to login to that group.
10:34 Exit from the user account asha.
10:38 Now switch to the terminal where we are logged in as a root user.
10:44 Now set the password for group biotech again.
10:48 I will type the new password as new_pass .
10:53 Retype the same password.
10:57 The group password is changed now.
11:00 Let’s check the entry for group biotech in the gshadow file.
11:06 We can see the encrypted password set here.
11:10 While using gpasswd command you should be careful about the following:
11:16 Except for the -A and -M options, other options cannot be combined.
11:24 Group administrator does not have permission to use gpasswd command with -A or -M option.
11:34 Switch to the terminal, in which we have logged in as a root user.

Exit from the root access.

11:42 This brings us to the end of this tutorial.

Let us summarize.

11:48 In this tutorial we learnt to

Set group administrator

11:54 Set group member
11:56 Add and delete user
11:59 Remove password of a group
12:02 Restrict access of a group
12:05 As an assignment-

Create a new group nanotech

12:10 Create four users: rajesh, sumita, anjan and chandan
12:17 Set rajesh as the administrator of the group nanotech
12:22 Set sumita and anjan as members
12:27 Add user chandan to the group
12:30 Remove sumita from the group
12:33 Check if user sumita can login to the group
12:38 At every step, check the entry in /etc/gshadow file
12:45 The video at the following link summarises the Spoken Tutorial project.

Please download and watch it.

12:53 The Spoken Tutorial Project team conducts workshops using spoken tutorials and gives certificates.

For more details, please write to us.

13:05 Please post your timed queries in this Forum.
13:09 Spoken Tutorial Project is funded by NMEICT, MHRD, Government of India.
13:15 The script has been contributed by Antara. And this is Praveen from IIT Bombay signing off.

Thanks for joining.

Contributors and Content Editors

PoojaMoolya