RHCSA RHCSA Linux Essentials 2 — Questions and Answers
Question 1: Which command displays the current SELinux enforcement mode?
- selinuxmode
- getenforce (Correct answer)
- sestatus --mode
- ls -Z /etc/selinux
Correct answer: getenforce
The `getenforce` command prints the current SELinux mode: Enforcing, Permissive, or Disabled.
Question 2: What does the `umask 027` setting mean for newly created files?
- Files get permissions 027
- Files get permissions 640 (Correct answer)
- Files get permissions 750
- Files get permissions 777
Correct answer: Files get permissions 640
Default file permissions are 666; subtracting umask 027 gives 666-027=640 (rw-r-----) for new files.
Question 3: Which systemd target is equivalent to the traditional SysV runlevel 3?
- multi-user.target (Correct answer)
- graphical.target
- rescue.target
- network.target
Correct answer: multi-user.target
multi-user.target is the systemd equivalent of runlevel 3 (multi-user, non-graphical).
Question 4: A user needs to edit /etc/sudoers safely. Which command should they use?
- vi /etc/sudoers
- nano /etc/sudoers
- visudo (Correct answer)
- sudo edit /etc/sudoers
Correct answer: visudo
`visudo` locks the file and validates syntax before saving, preventing a broken sudoers file.
Question 5: Which command permanently sets the hostname to 'server1.example.com'?
- hostname server1.example.com
- hostnamectl set-hostname server1.example.com (Correct answer)
- echo server1.example.com > /etc/hostname && reboot
- nmcli general hostname server1.example.com
Correct answer: hostnamectl set-hostname server1.example.com
`hostnamectl set-hostname` updates the hostname immediately and persists it across reboots.
Question 6: What is the effect of running `chmod g+s /shared/dir`?
- Files in the dir inherit the owner's UID
- Files in the dir inherit the group of the directory (Correct answer)
- The directory is only accessible by the group
- The sticky bit is set on the directory
Correct answer: Files in the dir inherit the group of the directory
The setgid bit on a directory causes new files created inside to inherit the directory's group rather than the creator's primary group.
Question 7: Which file contains the default shell for the root user?
- /etc/shells
- /etc/profile
- /etc/passwd (Correct answer)
- /etc/shadow
Correct answer: /etc/passwd
The /etc/passwd file stores each user's default shell in the seventh colon-delimited field.
Which command displays the current SELinux enforcement mode?