Centennial College Information and Communication Engineering Technology Course: CNET 222 Lab 4: Managing Users and Groups in Ubuntu
Centennial College Information and Communication Engineering Technology Course: CNET 222 Lab 4: Managing Users and Groups in Ubuntu
Centennial College
Information and Communication Engineering Technology
Lab 4:
Managing Users and Groups in Ubuntu
Instructions:
F. Shafique Page 1 of 11
CNET 222 Lab 4 Managing Ubuntu
Question 1: What do each of the seven fields represent? Hint: use the man pages by
typing the following command at the prompt: man 5 passwd.
F. Shafique Page 2 of 11
CNET 222 Lab 4 Managing Ubuntu
3. To view the numerical id the system relates with a particular user and their groups use
the id command followed by the username, for example, id root. Find the ids
associated with your user account (the one with your username).
Take screen shot # 1 showing the ids associated with your user.
4. The two commands to add a new user are useradd and adduser. You can use the
following commands to learn about them:
man useradd
man adduser
Take a look at the various options for these commands. Type q to exit from the manual
pages.
5. Now type the following command to create a new user:
sudo useradd –c “Elvis Presley” –m elvis
Enter your password when prompted.
Take screen shot # 2 showing the command ran without any error.
This will create a new user with username elvis and full name “Elvis Presley”.
Question 2: Has a home directory for user elvis been created? Hint: use the
command ls /home.
Question 3: What is the purpose of the –m option?
Note that since no password has been set for this user, you cannot login as elvis yet.
6. Set the password for user elvis with the following command:
sudo passwd elvis
When prompted, enter the password Pa$$w0rd. Confirm the password as required.
Take screen shot # 3 showing the command ran without error.
Question 4: Do you think you will be able to login as user elvis now?
F. Shafique Page 3 of 11
CNET 222 Lab 4 Managing Ubuntu
7. Note that the passwd command can be used to reset the password for any existing user
and to configure password properties such as password expiry. Set elvis’ password to
expire in 90 days with the following command:
sudo passwd -x 90 elvis
8. Let’s try another command to add a new user:
sudo adduser johnny
When prompted, enter the password Pa$$w0rd. When asked for the Full Name, give
Johnny Appleseed. Leave all other fields blank. Take screen shot # 4.
Question 5: Has a home directory for john been created?
Question 6: Do you think you can login as johnny?
F. Shafique Page 4 of 11
CNET 222 Lab 4 Managing Ubuntu
9. To create a new group use the groupadd command:
sudo groupadd students
10. We can use the id command and groups command to see what groups elvis is
currently a member of: id elvis; groups elvis
11. To add elvis to the students group, use the usermod command with –G option. Note
that the options are case sensitive and you must use a capital ‘G’. The lower case ‘g’
produces different results.
Question 7: Use the man pages to find the meaning of the –G and –g options, use the
command man usermod.
Now add elvis to the students group as follows:
sudo usermod –G students elvis
12. Use the id or groups command again to see what groups elvis is a member of. Take
screen shot # 5.
13. Now let’s add another group named celebrities using a different command and
add elvis to it:
sudo addgroup celebrities
sudo usermod –G celebrities elvis
groups elvis
F. Shafique Page 5 of 11
CNET 222 Lab 4 Managing Ubuntu
Note that elvis is now a member of the celebrities group but has been removed from
the students group. Find the appropriate option(s) of the usermod command so that
elvis is a member of both groups. Try out the command, check the result with the
groups command and take screen shot # 6 showing both the command you used and
the expected result shown below. Make sure the image shows the command you used.
14. Delete the group celebrities using the groupdel command:
sudo groupdel celebrities
15. Delete the user elvis with the userdel command:
sudo userdel elvis
16. Delete the user johnny: sudo userdel –r johnny
Take screen shot #7 showing all three deletions (celebrities, elvis and johnny).
Question 8: What is the purpose of the –r option in the userdel command?
Further Research:
- Look at the manual pages for the commands used in this lab:
• useradd
• usermod
• userdel
• groupadd
• groupdel
• passwd
F. Shafique Page 6 of 11
CNET 222 Lab 4 Managing Ubuntu
F. Shafique Page 7 of 11
CNET 222 Lab 4 Managing Ubuntu
3. To add a new user, click on the Add button. Enter your password when prompted. The
‘Create a new user’ dialog will appear. Fill out the required data for the new user,
including the full name and username.
Name: Elvis Presley
Username: elvis
4. Click on the OK button to add the new user. The ‘Change User Password’ dialog box
appears. Enter the password Pa$$w0rd twice and click OK.
Once added, the new user should appear in the list of users in the settings dialog and it
should be possible to login in using the new username and specified password.
Take screen shot # 8 showing user Elvis Presley in the list of users.
F. Shafique Page 8 of 11
CNET 222 Lab 4 Managing Ubuntu
5. Group membership can be managed from the User Settings too. Click on the Manage
Groups button on the middle left. Scroll down and select students, click Properties. In
the Group Member section, check ‘Elvis Presley’ to add elvis to the students
groups. Click OK. Enter your password if prompted and click OK.
6. On the ‘Group settings’ dialog box, click Add. The ‘New group’ dialog box opens.
7. Enter celebrities in the Group name text box, from the Group Member section select
‘Elvis Presley’ again and click OK. Scroll the list of groups to find the celebrities group
and click on Properties. Take screen shot # 9 showing the group members of the
celebrities group.
Click OK.
F. Shafique Page 9 of 11
CNET 222 Lab 4 Managing Ubuntu
8. To remove the celebrities group, select the group from the list and click Delete.
Confirm the deletion by clicking Delete. Then close the Group settings by clicking Close.
9. To remove the user, select Elvis Presley and click Delete. Click Delete Files.
Take screen shot # 10 showing the user is deleted.
10. Click Close to close the ‘User Settings’ window.
11. Remove the graphical user management tool with the following commands:
sudo apt remove -y gnome-system-tools
sudo apt autoremove
F. Shafique Page 10 of 11
CNET 222 Lab 4 Managing Ubuntu
Make sure you have all your work on your external USB hard disk.
F. Shafique Page 11 of 11