Operations 11 min read

Master Linux File Permissions: A Complete Guide to Using chmod

This tutorial explains the Linux chmod command, covering the permission model, how to view permissions with ls -l, numeric and symbolic notations, recursive changes, reference files, and multiple practical examples to help you manage file and directory access securely.

ITPUB
ITPUB
ITPUB
Master Linux File Permissions: A Complete Guide to Using chmod

What is chmod?

The chmod (change mode) command modifies file and directory permissions on Linux/Unix systems, controlling which users can read, write, or execute a given object.

Linux permission model

Each file or directory belongs to an owner (user), a group, and others. Permissions are expressed as read ( r), write ( w), and execute ( x) for each of these three categories. u – owner permissions g – group permissions o – others permissions

Viewing permissions

Use ls -l to list files with their permission strings. The first character indicates the type ( - regular file, d directory, l symlink). The next nine characters are three groups of rwx triples.

linuxmi@linuxmi:~/www.linuxmi.com$ ls -l
ls -l output
ls -l output

Numeric (octal) notation

Permissions can be set with a three‑digit (or four‑digit) octal number where each digit is the sum of read = 4, write = 2, execute = 1.

Read → 4

Write → 2

Execute → 1

Example: owner rwx = 7, group rx = 5, others r‑ = 4 → 754. $ chmod 754 filename Common shortcuts:

$ chmod 744 file.txt   # rwx for owner, r-- for group & others
$ chmod 750 file.txt   # rwx for owner, r-x for group, --- for others
$ chmod 755 file.txt   # rwx for owner & group, r-x for others

Symbolic notation

Symbolic mode uses [ugoa][+-=][rwx] to modify specific classes. $ chmod u+rwx,g=rw,o=r filename Operators: + – add permission - – remove permission = – set exact permission (clears previous)

Common examples

Assign read permission only to others:

$ chmod o=r file.txt
chmod o=r output
chmod o=r output

Add execute permission for owner and group:

$ sudo chmod ug+x file.txt
chmod ug+x result
chmod ug+x result

Set different permissions for each class:

$ sudo chmod u=rwx,g=rw,o=r filename
chmod u=rwx,g=rw,o=r result
chmod u=rwx,g=rw,o=r result

Remove all permissions from others (equivalent forms): $ sudo chmod o= filename or

$ sudo chmod o-rwx filename
chmod o= result
chmod o= result

Recursive changes

Use -R to apply permissions to a directory and all its contents.

$ chmod -R 755 /path/to/dir

Copy permissions from a reference file

The --reference option copies the mode of a template file to the target.

$ sudo chmod --reference=ref_file target_file
chmod --reference example
chmod --reference example

Apply execute permission only to directories

Uppercase X adds execute permission only to directories.

$ chmod a+X *

Summary

The chmod command provides flexible ways to view and modify file and directory permissions using numeric or symbolic notation, recursive options, and reference files, enabling precise access control in Linux environments.

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.

Linuxcommand-lineSystem AdministrationchmodFile Permissions
ITPUB
Written by

ITPUB

Official ITPUB account sharing technical insights, community news, and exciting events.

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.