Master Linux File Permissions: UGO, ACL, and chmod/chown Commands Explained
This guide explains Linux’s UGO permission model, the meaning of read/write/execute bits for files and directories, and demonstrates how to manage permissions using chmod, chown, chgrp, as well as advanced ACL techniques including mask and default settings.
Basic UGO Permissions
In Linux, permissions are assigned to three categories of users: U (owner), G (group), and O (others). Each category can have three basic rights: r (read, value 4), w (write, value 2), and x (execute, value 1).
Permission symbols
r--: read‑only
-w-: write‑only
--x: execute‑only
rw-: read and write
r-x: read and execute
-wx: write and execute
rwx: read, write, and execute
---: no permissions
File vs. directory semantics
For files,
rallows reading the content,
wpermits modifying the content, and
xis generally irrelevant except for executable binaries. For directories,
rlets you list entries,
wlets you create or delete entries, and
xallows you to enter the directory and access its contents.
Changing permissions with chmod
<code>chmod [options] <mode> <file...></code>Examples:
<code>chmod ugo+r a.conf
chmod u+rwx c.sh
chmod a+rw b.xml
chmod -R a+rw *
chmod 777 file # equivalent to u=rwx,g=rwx,o=rwx
chmod 600 file # owner read/write, others none</code>Changing ownership with chown
<code>chown [options] user[:group] file...</code>Example (requires root):
<code>chown tom:users d.key e.scrt
chown -R James:users *</code>Changing group with chgrp
<code>chown user1 f1 # change group ownership</code>Access Control Lists (ACL)
ACL extends the traditional UGO model, allowing fine‑grained permissions for individual users or groups.
Basic ACL commands
View ACL:
<code>getfacl /home/test.txt</code>Set ACL entry:
<code>setfacl -m u:alice:rw /home/test.txt</code>Mask permission
The mask defines the maximum effective permissions for ACL entries. It can be set with
-m:
<code>setfacl -m m::rw- file</code>Default permission
Default ACL entries are inherited by newly created files or sub‑directories within a directory. They are set with the
-doption:
<code>setfacl -d d::rw- directory</code>Important notes
Both mask and default entries use the
::syntax.
Permissions can be expressed numerically or symbolically.
Values must be within the range
-to
rwx.
Practical uses of file permissions
Control user access to files.
Prevent execution of malicious programs.
Protect the integrity and confidentiality of data.
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.