Operations 9 min read

Master Linux File Permissions: chown, chgrp, and chmod Explained

This guide walks through Linux's three identity classes and permission types, explains the output of ls -al, and provides detailed syntax and examples for changing owners with chown, groups with chgrp, and permissions with chmod using both symbolic and numeric methods.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Master Linux File Permissions: chown, chgrp, and chmod Explained

Introduction

Linux is a multi‑user, multitasking operating system that defines three identities for each file or directory—owner, group, and others—each with three possible permissions: readable, writable, and executable.

File Attributes

Running ls -al --full-time (or its alias ll) displays seven columns for each entry:

File type and permission bits (e.g., -r-xr-x--- means a regular file where the owner can read and execute, the group can read and write, and others have no permissions).

Link count.

Owner name.

Group name.

File size in bytes.

Last modification timestamp (not creation time).

File name (names starting with a dot are hidden).

Changing Owner (chown)

Location

etc/passwd

Syntax

chown [-R] [owner] [file|directory]

Use -R for recursive changes. You can also change the group at the same time with chown [-R] owner:group file, though chgrp is preferred for group changes.

Examples

chown daemon test          # change owner of "test" to daemon
chown daemon:root test     # change owner to daemon and group to root
chown root.users test     # change owner to root and group to users
chown .root test           # change only the group to root
Note: The specified owner must exist in /etc/passwd .

Changing Group (chgrp)

Location

etc/group

Syntax

chgrp [-options] group file|directory

Use man chgrp or chgrp --help for detailed options.

Example

chgrp -R users test   # recursively change group of "test" and its contents to users
Invalid group names will cause an error.

Changing Permissions (chmod)

Linux permissions consist of read (r), write (w), and execute (x) for each of the three identities, yielding nine possible permission bits.

Symbolic Method

Use u, g, o (or a for all) to select identities, r, w, x for permissions, and +, -, = to add, remove, or set permissions.

Set Permissions (=)

chmod u=rwx,g=rwx,o=rwx test   # give everyone read, write, execute
chmod ugo=rwx test
chmod a=rwx test

Remove Permissions (-)

chmod u-x,g-x,o-x test   # remove execute permission from everyone
chmod ugo-x test
chmod a-x test
Removing execute (x) on a directory prevents users from entering it with cd .

Add Permissions (+)

chmod u+x,g+x,o+x test   # add execute permission for everyone
chmod ugo+x test
chmod a+x test
Typical use: chmod a+x test.sh makes a shell script executable.

Numeric Method

Permissions are represented by numbers: read=4, write=2, execute=1. Sum them for each identity.

chmod 777 test   # rwx for owner, group, others
chmod 666 test   # rw- for all
chmod 755 test   # rwx for owner, r-x for group and others
The numeric method is often simpler.

File vs. Directory Permission Differences

Files

readable : can read file contents.

writable : can modify file contents.

executable : can be executed as a program.

Write permission on a file does not allow deletion; deletion is controlled by the directory's permissions.

Directories

readable : can list the directory contents (e.g., ls).

writable : can create, rename, move, or delete entries within the directory.

executable : can enter the directory (e.g., cd).

To allow browsing, a directory needs at least r or x . To read a file inside, the directory must have x and the file must have r .

Conclusion

Linux files can have separate rwx permissions for owner, group, and others. Use chown to change owners, chgrp to change groups, and chmod to modify permissions, thereby protecting data security.

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.

linuxSystem Administrationchgrpchmodchown
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

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.