GSEC · Question #14
The Linux command to make the /etc/shadow file, already owned by root, readable only by root is which of the following?
The correct answer is C. chmod 400/etc/shadow. The chmod 400 command sets file permissions so that only the owner has read access, which is the correct and minimal permission for the sensitive /etc/shadow file.
Question
The Linux command to make the /etc/shadow file, already owned by root, readable only by root is which of the following?
Options
- Achmod 444/etc/shadow
- Bchown root: root/etc/shadow
- Cchmod 400/etc/shadow
- Dchown 400 /etc/shadow
How the community answered
(42 responses)- A7% (3)
- B14% (6)
- C76% (32)
- D2% (1)
Why each option
The chmod 400 command sets file permissions so that only the owner has read access, which is the correct and minimal permission for the sensitive /etc/shadow file.
chmod 444 sets read permission for owner, group, AND others, which would allow all users to read the shadow file, defeating its security purpose.
chown root:root changes file ownership but does not modify permissions, so it would not enforce read-only access for root only.
chmod 400 sets permissions to read-only for the owner (root) and no permissions for group or others (octal 4=read, 0=none, 0=none). Since /etc/shadow already belongs to root, this ensures only root can read the file, protecting hashed passwords from unauthorized access. This is the minimal and correct permission set for this security-sensitive file.
chown is used to change file ownership, not permissions; '400' is not a valid argument for chown and this command would fail or produce an error.
Concept tested: Linux file permissions with chmod for sensitive files
Source: https://man7.org/linux/man-pages/man1/chmod.1.html
Topics
Community Discussion
No community discussion yet for this question.