CompTIA Linux+ Security and Access Control 1 — Questions and Answers
Question 1: Which of the following commands is used to add a new user to a Linux system?
- useradd
- adduser
- useradd -m
- Both A and B (Correct answer)
Correct answer: Both A and B
Both `useradd` and `adduser` commands are used to add new user accounts to a Linux system. While `useradd` is a low-level utility that requires more manual configuration, `adduser` is a more user-friendly script that often calls `useradd` internally and provides interactive prompts for common settings. Both achieve the goal of creating a new user.
Question 2: Which of the following files contains user account information on a Linux system?
- /etc/passwd
- /etc/shadow
- /etc/group
- All of the above (Correct answer)
Correct answer: All of the above
All three files are crucial for user account information. `/etc/passwd` stores basic user account details (username, UID, GID, home directory, shell). `/etc/shadow` stores encrypted user passwords and password aging information, providing enhanced security. `/etc/group` defines user groups and their members. Together, these files manage user identities and access.
Question 3: Which of the following is a correct example of setting file permissions using symbolic notation with the chmod command?
- chmod 755 file.txt
- chmod u+x file.txt
- chmod o-r file.txt
- All of the above (Correct answer)
Correct answer: All of the above
All the provided options are correct examples of setting file permissions using symbolic notation with the `chmod` command. `u+x` adds execute permission for the user, `o-r` removes read permission for others, and `755` is an octal notation that translates to `u=rwx,g=rx,o=rx` (read, write, execute for owner; read, execute for group and others). Symbolic notation uses letters and symbols to represent changes, offering flexibility.
Question 4: Which of the following commands is used to view the current SELinux status on a system?
- selinux --status
- setenforce
- sestatus (Correct answer)
- getenforce
Correct answer: sestatus
The `sestatus` command is used to display the current status of SELinux (Security-Enhanced Linux) on a system. It provides information such as whether SELinux is enabled or disabled, its current mode (enforcing, permissive, or disabled), and the policy being used. This command is essential for monitoring and managing SELinux security policies.
Question 5: What does the sudo command allow a user to do in a Linux system?
- Change user password
- Run commands as the root user or another user (Correct answer)
- Set file permissions
- Create a new user
Correct answer: Run commands as the root user or another user
The `sudo` command (substitute user do) allows a permitted user to execute a command as the superuser (root) or another user, as specified by the security policy. This provides a secure way to grant administrative privileges without sharing the root password. It enhances security by logging commands executed with elevated privileges.
Which of the following commands is used to add a new user to a Linux system?