Skip to main content

Quiz Module 5 - Users and Permissions

Instructions​

This quiz contains 30 multiple-choice questions to validate your understanding of Module 5.

Tip: Answer each question before revealing the answer. The answers are hidden just after each question.


Question 1​

What is the UID (User ID) of the root user?

See explanation

Correct answer: 0

Explanation: The root user always has UID 0. It is the unique identifier that gives it all privileges on the system.


Question 2​

Which command is used to create a user on Ubuntu 24.04?

See explanation

Correct answer: useradd or adduser

Explanation: useradd is the basic command to create a user. adduser (Ubuntu/Debian) is a more user-friendly interface that asks interactive questions. Example: sudo useradd -m -s /bin/bash username.


Question 3​

Which file contains user information?

See explanation

Correct answer: /etc/passwd

Explanation: /etc/passwd contains basic user information: name, UID, GID, home directory, shell. Format: username:x:UID:GID:comment:home:shell. Encrypted passwords are in /etc/shadow.


Question 4​

Which file contains encrypted user passwords?

See explanation

Correct answer: /etc/shadow

Explanation: /etc/shadow contains encrypted passwords and password policies. This file is readable only by root for security reasons.


Question 5​

Which command is used to modify an existing user?

See explanation

Correct answer: usermod

Explanation: usermod is used to modify an existing user. Examples: sudo usermod -s /bin/zsh username (change shell), sudo usermod -aG sudo username (add to sudo group), sudo usermod -L username (lock account).


Question 6​

Which command is used to delete a user?

See explanation

Correct answer: userdel

Explanation: userdel deletes a user. Options: sudo userdel username (keeps home), sudo userdel -r username (also deletes home directory). Option -f to force if active processes.


Question 7​

Which command is used to create a group?

See explanation

Correct answer: groupadd

Explanation: groupadd creates a new group. Examples: sudo groupadd developers, sudo groupadd -g 2000 developers (with specific GID).


Question 8​

Which file contains group information?

See explanation

Correct answer: /etc/group

Explanation: /etc/group contains group information: name, GID, members. Format: groupname:x:GID:members. Example: developers:x:1001:user1,user2,user3.


Question 9​

Which command is used to add a user to a group?

See explanation

Correct answer: usermod -aG

Explanation: sudo usermod -aG groupname username adds a user to a secondary group. The -a (append) option is important to not replace other groups. The user must log out/in for changes to take effect.


Question 10​

Which command is used to view a user's groups?

See explanation

Correct answer: groups or id

Explanation: groups displays the current user's groups. groups username shows a specific user's groups. id displays UID, GID, and all groups with more details.


Question 11​

Which command is used to change a file's owner?

See explanation

Correct answer: chown

Explanation: chown (change owner) modifies a file's owner and/or group. Examples: sudo chown user:group file, sudo chown user file, sudo chown -R user:group /directory (recursive).


Question 12​

Which command is used to modify a file's permissions?

See explanation

Correct answer: chmod

Explanation: chmod (change mode) modifies permissions. Syntaxes: chmod 755 file (octal), chmod u+x file (symbolic). Examples: chmod +x script.sh, chmod 644 file.txt, chmod -R 755 /directory (recursive).


Question 13​

What are the three basic permissions for Linux files?

See explanation

Correct answer: Read (r), Write (w), Execute (x)

Explanation: The basic Linux permissions are: read, write, execute. These permissions apply to the owner, group, and others.


Question 14​

What is the octal value for the permissions rwxr-xr-x?

See explanation

Correct answer: 755

Explanation: rwxr-xr-x = 111 101 101 in binary = 7 5 5 in octal. The owner has all permissions (7), the group and others have read and execute (5). This is the typical permission for executables.


Question 15​

Which command is used to run a command with root privileges?

See explanation

Correct answer: sudo

Explanation: sudo (superuser do) allows running a command with root privileges. Examples: sudo apt update, sudo systemctl restart service. Configuration is in /etc/sudoers.


Question 16​

Which file configures sudo?

See explanation

Correct answer: /etc/sudoers

Explanation: /etc/sudoers configures sudo permissions. Edit it with sudo visudo (checks syntax). Never edit directly with a normal editor to avoid syntax errors that could block sudo access.


Question 17​

What is the SUID (Set User ID) bit?

See explanation

Correct answer: A permission bit that allows a file to run with the owner's privileges

Explanation: The SUID bit (s) allows an executable to run with the owner's privileges, even if launched by another user. Example: passwd has SUID to allow users to change their password. Set with chmod u+s file or chmod 4755 file.


Question 18​

What is the SGID (Set Group ID) bit?

See explanation

Correct answer: A permission bit that allows a file to run with group privileges, or forces new files in a directory to belong to the group

Explanation: The SGID bit (s) on an executable allows it to run with group privileges. On a directory, it forces new files created to belong to the directory's group. Set with chmod g+s file or chmod 2755 file.


Question 19​

What is the sticky bit?

See explanation

Correct answer: A permission bit that prevents users from deleting other users' files in a directory

Explanation: The sticky bit (t) on a directory prevents users from deleting or renaming other users' files, even if they have write permissions. Useful for /tmp. Set with chmod +t directory or chmod 1777 directory.


Question 20​

Which command is used to see the current user?

See explanation

Correct answer: whoami or id

Explanation: whoami displays the current username. id shows more information: UID, GID, and all groups. id -u shows only the UID, id -g only the GID.


Question 21​

Which command is used to switch users?

See explanation

Correct answer: su

Explanation: su username switches users. su - username switches with the full environment (like a new login). su or su - switches to root. To exit, use exit.


Question 22​

What is the octal value for the permissions rw-r--r--?

See explanation

Correct answer: 644

Explanation: rw-r--r-- = 110 100 100 in binary = 6 4 4 in octal. The owner has read and write (6), the group and others have only read (4). This is the typical permission for text files.


Question 23​

What is an ACL (Access Control List)?

See explanation

Correct answer: An advanced permission system that allows granular permissions by user and group

Explanation: ACLs allow defining specific permissions for individual users or groups beyond standard permissions (owner/group/others). Commands: setfacl (set), getfacl (view). Example: setfacl -m u:user1:rw file.


Question 24​

Which command is used to view a file's ACLs?

See explanation

Correct answer: getfacl

Explanation: getfacl file displays a file or directory's ACLs. setfacl is used to set ACLs. Examples: setfacl -m u:user1:rw file (add permission), setfacl -x u:user1 file (remove ACL).


Question 25​

Which command is used to lock a user account?

See explanation

Correct answer: usermod -L

Explanation: sudo usermod -L username locks a user account (adds a ! in front of the password hash in /etc/shadow). sudo usermod -U username unlocks. sudo passwd -l username does the same.


Question 26​

What is the difference between the primary group and secondary groups?

See explanation

Correct answer: A user has only one primary group but can belong to multiple secondary groups

Explanation: The primary group is defined in /etc/passwd and is used by default for new files. Secondary groups are in /etc/group and provide additional permissions.


Question 27​

Which command is used to change a user's password?

See explanation

Correct answer: passwd

Explanation: passwd changes the current user's password. sudo passwd username allows root to change another user's password. sudo passwd -l username locks an account.


Question 28​

What is the octal value for the permissions rwxrwxrwx?

See explanation

Correct answer: 777

Explanation: rwxrwxrwx = 111 111 111 in binary = 7 7 7 in octal. Everyone (owner, group, others) has all permissions. This is generally too permissive and not recommended for security reasons.


Question 29​

Which command is used to see connected users?

See explanation

Correct answer: who or w

Explanation: who displays connected users with their terminals and login times. w shows more information: users, terminals, connection times, system load, and current commands. users just lists the names.


Question 30​

Which command is used to delete a group?

See explanation

Correct answer: groupdel

Explanation: sudo groupdel groupname deletes a group. The group cannot be deleted if it is the primary group of a user. You must first change the user's primary group or delete the user.


Quiz Result​

Congratulations on completing the Module 5 quiz!

Score:

  • 25-30 correct answers: Excellent! You master Linux user and permission management.
  • 20-24 correct answers: Very good! Review the concepts where you had difficulties.
  • 15-19 correct answers: Good! Review the chapters on users and permissions.
  • Less than 15: Recommended to review the module before continuing.

Next Steps​

Now that you have validated your knowledge:

Module 6: Shell Scripting
Practical Labs: Practice user and permission management with Module 5 labs


Quiz created on: December 2024 - Tested on Ubuntu 24.04