RH124 Ch 6: Users, Groups and sudo

Every process runs as a user. Accounts live in /etc/passwd (name, UID, GID, home, shell), password hashes and ageing in /etc/shadow, groups in /etc/group. Each user has one primary group (owner group of new files) and any number of supplementary groups.

Accounts - useradd -u 2001 -G wheel,finance -s /bin/bash -c "Asha K" asha - usermod -aG finance ravi — -a appends; without it -G replaces all supplementary groups. - userdel -r olduser also removes the home directory. - groupadd -g 3000 finance, groupmod, groupdel; id user shows memberships. - useradd -s /sbin/nologin svc makes an account that cannot log in.

Passwords and ageing - passwd user; in scripts echo 'Pass' | passwd --stdin user. - chage -M 90 user maximum days, -m minimum, -W warning days, -E 2026-12-31 account expiry, -d 0 force change at next login. chage -l user shows the result. - Defaults for new accounts: PASSMAXDAYS in /etc/login.defs.

Switching users: su - user starts a login shell as that user; sudo command runs one command as root and logs it. Members of wheel may use sudo on RHEL.

sudo rules go in /etc/sudoers.d/<file (edit with visudo -f, check with visudo -c): - %finance ALL=(root) /usr/bin/systemctl — one command. - %devops ALL=(ALL) ALL — everything, with a password; add NOPASSWD: before the command list to skip it.

Exam traps: forgetting -a with usermod -G, setting ageing on the wrong user, and leaving a syntax error in sudoers (always run visudo -c).