You are on page 1of 5

Kingdome of Saudi Arabia ‫المملكة العربية السعودية‬

Ministry of Higher Education ‫وزارة التعليم العالي‬


Taibah University ‫جـامـعـة طـيـبـة‬
College of Computer Science and ‫كلية علوم وهندسة الحاسب اآللي‬
Engineering ‫قسم نظم المعلومات‬
Department of Information Systems
IS253 – Operating Systems Configuration and Use
Linux-Unit 5 (ch07) Activities

Activity 7-1: Creating Users


Objective: Create users with the useradd command and user database files.
1. Start VMware Player and start an openSUSE virtual machine.
2. Open a terminal window and display the last 10 lines of your passwd file by typing tail /etc/passwd and
pressing Enter. Find the entry for your user account. For instance, for a user logged in as amber, the entry
would look like this: amber:x:1000:100:Amber Dawn:/home/amber:/bin/bash.
3. Try to view the /etc/shadow file by typing tail /etc/shadow and pressing Enter. Were you able to view this
file? Why?
______________________________________________________________________________________
4. Type su and press Enter, and then enter the root password. To see the last 10 lines of the /etc/shadow file,
type tail /etc/shadow and press Enter. Find the user you’re currently logged in as and examine the entry
for this user account.
5. View the contents of one of your user account configuration files (login.defs) by typing less /etc/login.defs
and pressing Enter. Use the arrow keys (or mouse wheel) to scroll through this file. Find the password
aging settings and compare the entries in this file with the information you viewed in Step 4. Which fields
in the /etc/shadow file show the same password-setting information that’s in /etc/login.defs? When you’re
finished examining this file, press q to exit the less command.
______________________________________________________________________________________
6. The useradd file contains basic user account creation information, such as the location of the skeleton
directory. To find your skeleton directory, type cat /etc/default/useradd and press Enter. In openSUSE,
the default skeleton directory is /etc/skel. Change to the skeleton directory by typing cd /etc/skel and
pressing Enter.
7. Display a long listing of files and subdirectories in your current directory (/etc/skel) by typing ls -l and
pressing Enter. The files and directories you see are the ones copied to a new user’s home directory.
8. Review the options for the useradd command by typing useradd --help and pressing Enter. Remember
that you must be logged in as root to issue this command.
9. Create a user and add a home directory by typing useradd -m student1 and pressing Enter.
10. Type tail /etc/shadow and press Enter. Find the student1 entry and notice that the password field has only
the ! symbol, which means the password hasn’t been set for this user.
11. Set the password for student1 by typing passwd student1 and pressing Enter. Type Op3n$U$e as the new
password and press Enter, and then enter the password again to confirm.
12. Type tail /etc/shadow and press Enter. Find the student1 entry, and confirm that the password field now
contains a password instead of the ! symbol. (Remember that this password is encrypted.)
13. Display a long listing of files and subdirectories in student1’s home directory by typing ls -l
/home/student1 and pressing Enter. Compare the results with the results in Step 7.
______________________________________________________________________________________
14. Type exit and press Enter to exit the root user account. Type su - student1 and press Enter to switch to
the student1 user account, and then type Op3n$U$e as the password and press Enter.
15. Now that you have logged in as student1, you can exit this user account and return to your regular user
account by typing exit and pressing Enter. Leave the terminal window open and the virtual machine
running for the next activity.

Lab Activities Page 1


Kingdome of Saudi Arabia ‫المملكة العربية السعودية‬
Ministry of Higher Education ‫وزارة التعليم العالي‬
Taibah University ‫جـامـعـة طـيـبـة‬
College of Computer Science and ‫كلية علوم وهندسة الحاسب اآللي‬
Engineering ‫قسم نظم المعلومات‬
Department of Information Systems
IS253 – Operating Systems Configuration and Use
Linux-Unit 5 (ch07) Activities
Activity 7-2: Modifying User Accounts
Objective: Modify user accounts with the usermod and chage commands.
Note: If you didn’t complete Activity 7-1, use the commands you’ve learned in this chapter to create a user
called student1.

1. If your terminal window is still open, switch to the root user by typing su, pressing Enter, and then
entering the correct root user password. If you don’t have a terminal window open or if VMware Player
isn’t running, follow Step 1 of Activity 7-1.
2. Find the student1 password entry in the /etc/passwd file by typing cat /etc/passwd | grep student1 and
pressing Enter. (Note: If you didn’t complete Activity 7-1, there won’t be an entry for student1.) Write
down this entry so that you can compare it with the results after you modify the account. The student1 entry
should look something like the following:
student1:x:1011:100::/home/student1:/bin/bash
3. Change student1’s home directory by typing usermod -d /home/student1/scripts student1 and pressing
Enter. Create the new directory by typing mkdir /home/student1/scripts and pressing Enter. Type cat
/etc/passwd | grep student1 and press Enter, and then compare the new student1 entry with what you
wrote down in Step 2. The new student1 entry should look something like the following:
student1:x:1011:100::/home/student1/scripts:/bin/bash
4. Change student1’s login name by typing usermod -l student2 student1 and pressing Enter.
5. Type cat /etc/passwd | grep student2 and press Enter, and compare the results with those in Step 4.
Notice that all the information stayed the same (including the home directory) except the first field, which
is the login name. The new student2 entry should look something like the following:
student2:x:1011:100::/home/student1/scripts:/bin/bash
6. Switch to the student2 user by typing su - student2 and pressing Enter. Display the expiration information
for the student2 account by typing chage -l (the lowercase L, not the number 1) and pressing Enter. Enter
student2’s password (Op3n$U$e) and press Enter. The results should look like the following:
Password:
Minimum: 0
Maximum: 99999
Warning: 7
Inactive: -1
Last Change: May 14, 2012
Password Expires: Never
Password Inactive: Never
Account Expires: Never
7. Switch back to the root user by typing exit and pressing Enter.
8. Use the chage command in interactive mode by typing chage student2 and pressing Enter.

Lab Activities Page 2


Kingdome of Saudi Arabia ‫المملكة العربية السعودية‬
Ministry of Higher Education ‫وزارة التعليم العالي‬
Taibah University ‫جـامـعـة طـيـبـة‬
College of Computer Science and ‫كلية علوم وهندسة الحاسب اآللي‬
Engineering ‫قسم نظم المعلومات‬
Department of Information Systems
IS253 – Operating Systems Configuration and Use
Linux-Unit 5 (ch07) Activities
9. To set the minimum password age, type 3 and press Enter. To set the maximum password age, type 90 and
press Enter. Next, you set the password expiration warning. The number 7 in brackets is the default, and if
you press Enter, this setting is accepted. Press Enter to accept the rest of the defaults. When you’re done,
you get the message “Aging information changed.” Your screen should look like the following:
client:/home/dustin # chage student2
Changing aging information for student2.
Minimum Password Age [0]: 3
Maximum Password Age [99999]: 90
Password Expiration Warning [7]:
Password Inactive [-1]:
Last Password Change (YYYY-MM-DD) [2012-05-16]:
Account Expiration Date (YYYY-MM-DD) [1969-12-31]:
Aging information changed.
10. To specify that student2 must wait 1 day after getting a new password before changing it and the password
expires every 45 days with 3 days of warning before expiration, what command do you use?
______________________________________________________________________________________
11. Exit the root user account and return to your regular user account by typing exit and pressing Enter. Leave
the terminal window open and the virtual machine running for the next activity.

Lab Activities Page 3


Kingdome of Saudi Arabia ‫المملكة العربية السعودية‬
Ministry of Higher Education ‫وزارة التعليم العالي‬
Taibah University ‫جـامـعـة طـيـبـة‬
College of Computer Science and ‫كلية علوم وهندسة الحاسب اآللي‬
Engineering ‫قسم نظم المعلومات‬
Department of Information Systems
IS253 – Operating Systems Configuration and Use
Linux-Unit 5 (ch07) Activities
Activity 7-3: Working with Groups
Objective: Create and modify groups with the groupadd, groupmod, and newgrp commands.
1. If your terminal window is still open, switch to the root user by typing su, pressing Enter, and then
entering the correct root user password. If you don’t have a terminal window open or if VMware Player
isn’t running, follow Step 1 of Activity 7-1.
2. View all groups and group members on your system by typing less /etc/group and pressing Enter. Scroll
through the file with the arrow keys or mouse wheel. Press q to exit the less command.
3. Create a new group by typing groupadd students and pressing Enter. Display the students group by typing
cat /etc/group | grep students and pressing Enter. The cat command used with a pipe (|) to the grep
command searches for “students” in the etc/group file and then displays it. How many users are assigned to
this group?
______________________________________________________________________________________
4. Add your regular user account as a member of the students group by typing usermod –G students login
name and pressing Enter. Display the students group again by typing cat /etc/group | grep students and
pressing Enter. Examine the fourth field of the students entry, and notice that your user login name is
added.
5. Switch to your regular user account by typing exit and pressing Enter.
6. Create a new directory by typing mkdir Act7-3 and pressing Enter, and then switch to this directory by
typing cd Act7-3 and pressing Enter. Create an empty file by typing touch file1 and pressing Enter.
Switch your primary group to students by typing newgrp students and pressing Enter. Now create a
second file by typing touch file2 and pressing Enter.
7. View a long listing of files and directories by typing ls -l and pressing Enter. What’s the difference
between file1 and file2?
______________________________________________________________________________________
8. Switch to the root user by typing su, pressing Enter, and entering the correct root user password. Remove
the user you added in Step 4 from the students group by typing groupmod -R login name students and
pressing Enter. Type cat /etc/group | grep students and press Enter. Notice that there are no users in the
fourth field.
9. Exit the root user account and return to your regular user account by typing exit and pressing Enter. Leave
the terminal window open and the virtual machine running for the next activity.

Lab Activities Page 4


Kingdome of Saudi Arabia ‫المملكة العربية السعودية‬
Ministry of Higher Education ‫وزارة التعليم العالي‬
Taibah University ‫جـامـعـة طـيـبـة‬
College of Computer Science and ‫كلية علوم وهندسة الحاسب اآللي‬
Engineering ‫قسم نظم المعلومات‬
Department of Information Systems
IS253 – Operating Systems Configuration and Use
Linux-Unit 5 (ch07) Activities
Activity 7-4: Using the YaST User and Group Management Utility
Objective: Add users and groups in the YaST User and Group Management utility.
1. If necessary, start VMware Player and start your GNOME openSUSE virtual machine.
2. Open the YaST Control Center by clicking the Computer button at the lower left. On the right, click the
YaST icon in the System section. When prompted, enter your root password.
3. Find the User and Group Management utility by typing user in the Filter text box, and then clicking the
utility name under Security and Users. (You can also type yast2 users and press Enter while logged in as
the root user.)
4. Create a new user by clicking Add and then entering the following information:
User’s Full Name: Activity 7-4 Student
Username: student3
Password: Op3n$U$e
5. View the user account details by clicking the Details tab. Write down the user ID, home directory, login
shell, and default group.
______________________________________________________________________________________
6. Force the user to change his or her password by clicking the Password Settings tab and clicking the Force
Password Change check box. How many days before the password expires will the user get a warning?
What does the 99999 value for the Maximum Number of Days for the Same Password setting mean?
______________________________________________________________________________________
7. Create the user account by clicking OK at the bottom.
8. Create a new group by clicking the Groups tab and clicking Add. Enter the following information:
Group Name: classroom
Group ID (gid): Leave the default information
Password: Leave blank
9. On the right is the Group Members section. Add student3 as a member of the classroom group by clicking
the student3 check box. Confirm the new group by clicking OK at the lower right.
10. Save the user and group information by clicking OK at the lower right.
11. You can use the command line to make sure everything was done correctly. To do this, open a terminal
window, and then switch to the student3 user by typing su - student3 and pressing Enter. Type the
student3 password and press Enter.
12. Because the settings changed in Step 6, you must change student3’s password. First, enter the old password
(Op3n$U$e) and press Enter. Type a new password and press Enter, and then enter this new password
again to confirm.
13. To verify that student3 is a member of the classroom group, type id and press Enter.
14. Close the terminal window, and shut down your openSUSE virtual machine.

Lab Activities Page 5

You might also like