1) Add users
a) Add a user named “roger” (or, create your own username) using the “useradd” command.
useradd -d /home/roger -m roger
b) Create a password for the new user using the “passwd” command
c) Login using the new account.
d) Repeat step a) to c) to create 2 or 3 other users.
e) Examine the home directory of each user under /home/.
f) Examine the following files and see what’s added for the users/groups you created. Try to understand the new additions.
g) Create two groups: managers, staff
h) Add roger to the “managers” group; add other users you have created to the “staff” group.
i) Create some files and directories in /etc/skel.
j) Create a new user and then login to examine his/her home directory. What has been created already in the home
k) Add Roger to a new group called “committee”.
l) Use the “id” or “groups” command to check users and groups information and see if they are in the right groups.
2) Create a new user with following information. Try to use fewer commands to complete the task.
a) User name: bbrown
b) Primary group: faculty
c) Other groups: web-author, coordinator
d) Temporary password: bob (the user needs to change it when login for the first time)
e) How many commands did you use?
f) Take two screenshots
i) Execute “id bbrown” on the command line. Take a screenshot of the execution results (#7-1).
ii) Display the content of the “passwd” file. Show the line for the user “bbrown”. Take a screenshot (#7-2).
3) Hashing user password
a) Go to Password Hash Generator – <link is hidden> /> b) Enter Password: “password” twice
c) Choose the DES algorithm.
d) Enter the salt “Np”.
e) Click Calculate DES Crypt and see the output value. Use this value for the next exercise.
4) Manipulating /etc/passwd directly
a) Copy (or type) the following user information line (values separated by colon) and paste it to the last line in the file, and
save the file. The second part is the hashed value from last exercise.
it4423test:Npge08pfz4wuk:1010:1010:it4423 test user:/home/it4423test:/bin/sh
b) Create the home directory “/home/it4423test” and change the owner to “it4423test”. Use “ls -l” to verify it.
chown it4423test /home/it4423test
c) Login with the new user “it4423test” and the password is “password” (the “Npge08pfz4wuk” part is the hash value of
“password” – don’t use it in the real life). If you use Gnome, you can quickly switch to the account using the switch menu
(see figure 1 below). Or use the “su” command.
d) Login with the root account (or simply logout if you switched user using the menu)
e) Delete the test user using the “userdel” command.
5) Query users and groups
a) Login with all your new users (use the login command). Use “w” or “who” command to see current users. Compare the
output format between the two commands.
b) Use “whoami”, or “who am i” command to see your own login. Compare the output format between the two commands.
c) Search for users: how to search for a user using part of his login name? (Hint: use “grep”.) Can you write a script to do it?
d) How to list all members in a particular group? Can you write a script to do it?
6) I have a directory named “d1” with a text file “f1” in it. The permission of “f1” is “700” and the permission of “d1” is 400. I am
the owner of “f1” and “d1”. Briefly describe and explain some possible results if I try to list the directory content using the “ls
d1” command (with different options).
Question: Linux User Management
1) Add users