3. Linux Permissions, User Management & ACL
Modules 5 & 6: Chmod 755/644, chown, SUID, SGID, Sticky bit, ACL getfacl/setfacl, useradd, usermod, /etc/passwd, /etc/shadow
Module 1: File Permissions, Ownership & Access Control Lists (ACL)
Securing Linux resources with numeric/symbolic permissions, special bits, and fine-grained ACLs.
🇬🇧 English Definition
Permissions are defined for owner, group, and others: read (r=4), write (w=2), execute (x=1). SUID (4), SGID (2), and Sticky Bit (1) provide specialized execution and deletion security controls.
🇮🇳 Hinglish Definition
Permissions me owner, group aur others ke read/write/execute controls hote hain. ACL specific users/groups ko finer-grained access deta hai.
Core Concepts & Rules
- Octal Mode 755: Owner rwx (7), Group r-x (5), Others r-x (5).
- SUID (4755): Executable runs with effective permissions of file owner.
- Sticky Bit (1777): Applied to shared folders (like /tmp) restricting file deletion/rename strictly to file owner.
🔍 Line-by-Line Command Breakdown
- Line 1: chmod 755 script.sh sets rwxr-xr-x permissions on script.
- Line 2: chown user:group file changes file owner user and group.
- Line 3: getfacl file displays ACL fine-grained permissions.
- Line 4: setfacl -m u:alice:r file grants user alice explicit read access via ACL.
🎯 Interview Focus & Questions
- Q: What does 755 mean?
A: Owner has rwx (4+2+1=7); group and others have r-x (4+0+1=5). - Q: chmod vs chown?
A: chmod changes permissions; chown changes ownership. - Q: What is SUID?
A: An executable with SUID runs with the file owner's effective privileges. - Q: What is sticky bit?
A: On a shared directory it restricts deletion/rename to the file owner, directory owner, or root.
ls -l file
chmod 644 file
chmod 755 script.sh
chown user:group file
chgrp group file
getfacl file
setfacl -m u:alice:r file
chmod 4755 program
chmod 1777 shared_dir
Module 2: User & Group Administration
Managing user accounts, password security, group memberships, and system login files.
🇬🇧 English Definition
User administration covers account creation, passwords, default shells, home directory provisioning, locking, deletion, and group memberships. Crucial files include /etc/passwd, /etc/shadow, and /etc/group.
🇮🇳 Hinglish Definition
User management Linux Admin ka major task hai: user create, password set, group assign, shell/home manage aur account lock/unlock.
Core Concepts & Rules
- /etc/passwd: Stores user account details, UID, GID, home path, and shell.
- /etc/shadow: Stores secure encrypted password hashes accessible only by root.
- usermod -aG: Appends a user to supplementary groups without overwriting existing group memberships.
🔍 Line-by-Line Command Breakdown
- Line 1: useradd -m -s /bin/bash alice creates user alice with home directory and bash shell.
- Line 2: passwd alice sets or updates password for user alice.
- Line 3: usermod -aG sudo alice adds alice to sudo supplementary group.
- Line 4: usermod -L alice locks user account alice.
🎯 Interview Focus & Questions
- Q: UID vs GID?
A: UID (User ID) identifies a user; GID (Group ID) identifies a group. - Q: Primary vs supplementary group?
A: A user has one primary group and may belong to additional supplementary groups. - Q: Where are password hashes stored?
A: Typically /etc/shadow, protected from ordinary users.
sudo useradd -m -s /bin/bash alice
sudo passwd alice
sudo usermod -aG sudo alice
id alice
groups alice
sudo usermod -L alice
sudo usermod -U alice
sudo userdel -r alice