Users, groups, and permissions
This domain, Users, groups, and permissions, tests account management and the permission model that decides who may read, write, or execute what, including special bits, umask, and ACLs.
Accounts and groups
/etc/passwdholds name, UID, GID, GECOS, home, and shell;/etc/shadowholds the hash and aging data;/etc/groupand/etc/gshadowdefine groups.- UID 0 is root; system accounts usually sit below 1000; regular users start at 1000 on most distributions.
useradd -m -s /bin/bash,usermod -aG wheel alice(append, never omit-a),passwd,chage -l,id,groups.sudois configured in/etc/sudoersthroughvisudo; membership inwheel(RHEL) orsudo(Debian) is the usual grant.
Permissions
- Three triads (owner, group, other) with
r=4,w=2,x=1. Examples:chmod 640 file,chmod g+w,o-rwx file,chown alice:dev file. - On directories,
xmeans traverse,wmeans create and delete entries,rmeans list names. - Special bits: setuid (4) runs as the file owner; setgid (2) on a directory makes new files inherit the group; sticky (1) on a shared directory stops users deleting each other's files (
/tmpis 1777). umasksubtracts from base 666 for files and 777 for directories, soumask 027yields files of 640 and directories of 750.- ACLs:
setfacl -m u:bob:r-- file, inspected withgetfacl.
Worked example
A file shows -rw-r----- 1 alice dev 1024 .... Owner alice reads and writes, group dev reads, others get nothing. To let bob read it without changing the group, run setfacl -m u:bob:r-- file. Reasoning: the ACL adds a per-user entry while leaving the traditional triad intact, and ls -l will show a + marker.
Traps
usermod -Gwithout-awipes supplementary group membership.- Group changes need a fresh login or token to take effect.
- setuid is ignored on scripts for security reasons.
- Deleting a file depends on write permission on the directory, not on the file.