Fundamentals 8 min read

Master Linux File Permissions: chown, chmod, and Numeric Modes Explained

This guide explains how Linux manages file ownership and access rights, covering the use of chown, chgrp, and chmod commands, interpreting symbolic and numeric permission strings, and providing practical examples for changing owners, groups, and permission bits.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Master Linux File Permissions: chown, chmod, and Numeric Modes Explained

Linux File Ownership and Permissions

Linux is a multi‑user operating system; each file has an owner, a group, and permission bits that control read, write, and execute access for the owner, the group, and other users.

Viewing file attributes

# ls -l
total 64
drwxr-xr-x 2 root root 4096 Dec 14 2012 bin
...

Permission string format

First character indicates the file type: d directory, - regular file, l symbolic link, b block device, c character device.

The next nine characters are three groups of rwx representing read, write, and execute permissions for owner, group, and others. A dash ( -) means the permission is absent.

Numeric (octal) representation

Permission values: r=4, w=2, x=1. Add the values for each class to obtain a three‑digit octal code.

Owner rwx → 7

Group rwx → 7

Others --- → 0

Resulting mode: 770. The chmod syntax is:

chmod [-R] xyz file_or_directory

Changing ownership

chgrp

changes the group; chown changes the owner and optionally the group.

# Change group
chgrp [-R] group_name file_name

# Change owner only
chown user file_name

# Change owner and group
chown user:group file_name

Modifying permissions with chmod

Numeric example – give full access to a file:

# Show current mode
ls -al .bashrc
# Set mode to 777 (rwx for all)
chmod 777 .bashrc
# Verify change
ls -al .bashrc

Symbolic example – set mode to -rwxr-xr--: chmod u=rwx,g=rx,o=r file_name Remove a permission without affecting others (e.g., strip execute bits from everyone):

chmod a-x file_name

Symbolic mode components

Classes: u (owner), g (group), o (others), a (all).

Operators: + (add), - (remove), = (set).

Permissions: r, w, x.

Recursive changes

Both chgrp and chown accept the -R flag to apply the change recursively to all files and sub‑directories.

Practical examples

# Change owner of install.log to user "bin"
chown bin install.log

# Change back to root:root
chown root:root install.log

# Change group recursively
chgrp -R developers /opt/project

# Set permissions recursively (755 = rwxr-xr-x)
chmod -R 755 /var/www/html
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxUnixchmodchownFile Permissions
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.