Set secret.txt to owner read/write, group read, and no permissions for others.
Which command is appropriate?
Octal mode 640 means owner 6 (rw), group 4 (r), and other 0 (---).
Detailed explanation
chmod 460 secret.txtIncorrect. 460 assigns the digits to the wrong classes.
Incorrect. 460 assigns the digits to the wrong classes.
chmod 604 secret.txtIncorrect. 604 grants other users read permission and changes the intended classes.
Incorrect. 604 grants other users read permission and changes the intended classes.
chmod 640 secret.txtCorrect. chmod 640 secret.txt sets rw-r-----.
Correct. chmod 640 secret.txt sets rw-r-----.
chmod 644 secret.txtIncorrect. 644 grants other users read permission.
Incorrect. 644 grants other users read permission.
Try it yourself
An example you can run in a temporary verification environment.
tmp=$(mktemp); chmod 640 "$tmp"; stat -c '%A %a' "$tmp"; rm -f "$tmp"Expected result
-rw-r----- 640Key points
- Read=4
- Write=2
- Owner/group/other order
Notes
- Environment: GNU coreutils 9.x / 一時ファイル
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.