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.
chmod 604 secret.txtIncorrect. 604 grants other users read permission and changes the intended classes.
chmod 640 secret.txtCorrect. chmod 640 secret.txt sets rw-r-----.
chmod 644 secret.txtIncorrect. 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 / 一時ファイル
- Use a disposable file or directory when checking chmod calculations.
- Exact permission display can vary slightly with filesystem and distribution defaults.
Foundation review
Place the operation
640 means owner read/write, group read, and no ordinary permission for other users.
Check the side effect
Keep the three octal digits aligned with owner, group, and other; do not swap group and other.