Master Linux Permissions: From chmod to SUID, ACLs and sudo
This guide explains Linux file permission fundamentals, covering owner/group/other rights, chmod and chown usage, umask defaults, special bits like SUID/SGID/Sticky, ACL management, sudo configuration, and essential system commands for effective operations.
1. Permission Overview
Linux file permissions are defined for three classes of users: owner (u), group (g), and others (o). Each class can have read (r), write (w), and execute (x) permissions. Directories also have r (list), w (create/delete), and x (enter) bits.
Permission bits can be represented in binary or octal; the umask masks default permissions.
2. Permission Management Commands
2.1 chmod
Use
chmod MODE file...to change permissions. Options include -R for recursive, specifying user classes (u,g,o,a) and adding or removing bits with + or -.
# chmod u-w 111
# chmod o+w 111
# chmod a=rwx 1112.2 chown
Only root can use
chownto change file owner and group.
# chown user:group file
# chown -R user:group directory3. Umask and Default Permissions
The default file mode (e.g., 644) and directory mode (755) are controlled by the umask. Example:
umask 022results in files created with 644 and directories with 755.
4. Linux Security Context and Special Permissions
4.1 Security Context
Execution permission determines whether a program can be started; the resulting process inherits the initiator’s UID and GID.
4.2 Special Permissions
SUID (4), SGID (2), and Sticky (1) modify the usual ownership rules. Use
chmod u+s filefor SUID,
chmod g+s dirfor SGID, and
chmod o+t dirfor Sticky.
5. Filesystem Access Control Lists (facl)
ACLs provide fine‑grained permissions beyond the traditional model. Commands:
setfacl -m u:UID:perm file,
setfacl -x u:UID file,
getfacl file, and
setfacl -b fileto remove all ACL entries.
6. sudo
sudo allows a user to run commands as another user. Configuration is in
/etc/sudoersedited with
visudo. Syntax:
who which_hosts=(runas) command. Various options control behavior, such as
-lto list privileges,
-Vfor version, etc.
7. Management Commands
Common utilities:
wshows logged‑in users,
lastdisplays login history,
sleeppauses execution,
basenameextracts the filename, and others for system monitoring.
Raymond Ops
Linux ops automation, cloud-native, Kubernetes, SRE, DevOps, Python, Golang and related tech discussions.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.