Fundamentals 11 min read

Master Linux Permissions: From Basics to Advanced Control

This guide walks you through Linux permission fundamentals, covering user categories, switching users, sudo usage, permission representation, file types, basic rwx bits, octal notation, and how to modify permissions with chmod, chown, chgrp, umask, as well as directory sticky bits.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Master Linux Permissions: From Basics to Advanced Control

Linux Permission Basics

Linux uses a permission model to control which users can read, write, or execute files and directories. Permissions are evaluated per file system object and consist of three role groups: owner (u), group (g), and others (o).

User categories

Root (superuser) : unlimited access, prompt #.

Normal user : limited privileges, prompt $.

Switching users

Use su or su - to become the superuser (password required). Use exit or press Ctrl+D to return to the previous user.

sudo command

Syntax: sudo command. Allows a normal user to execute a command with root privileges if the user is listed in /etc/sudoers.

Permission representation

Each role has three bits: read ( r, value 4), write ( w, value 2), execute ( x, value 1). Absence of a permission is shown as -. Example: rwxr-xr-- corresponds to octal 754 ( 7 =rwx, 5 =r‑x, 4 =r‑‑).

The first character of ls -l output indicates the file type: -: regular file d: directory l: symbolic link b: block device c: character device p: pipe s: socket

Modifying Permissions

chmod command

Syntax: chmod [options] mode file. Common option -R applies changes recursively.

Mode can be expressed symbolically, e.g., u+rwx,g+rx,o-r, or numerically in octal, e.g., 754. To set permissions directly: chmod 754 filename.

chown command

Syntax: chown [options] user[:group] file. Example: chown hjz hello.txt changes the owner of hello.txt to hjz.

chgrp command

Syntax: chgrp [options] group file. Example: chgrp hjz hello.txt changes the group ownership of hello.txt to hjz.

umask command

umask

displays or sets the default permission mask. New files start with mode 666 and directories with 777; the final mode is calculated as final = initial & (~umask). For example, umask 022 yields files with mode 644 and directories with 755.

Directory Permissions and Sticky Bit

Directory permission bits

Execute (x) : required to cd into the directory.

Read (r) : allows listing the directory’s contents.

Write (w) : permits creating, renaming, or deleting entries; deletion is governed by the directory’s write and execute bits, not the file’s own permissions.

Sticky bit

Set with chmod +t directory. When the sticky bit is set, only the file’s owner, the directory’s owner, or root may delete or rename files within that directory. This is commonly used on /tmp to prevent users from removing each other’s temporary files.

Linux permission illustration
Linux permission illustration
User categories
User categories
chmod symbolic example
chmod symbolic example
chmod octal example
chmod octal example
chown example
chown example
chgrp example
chgrp example
umask example
umask example
home directory permissions
home directory permissions
sticky bit example
sticky bit example
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.

PermissionschmodSudoumask
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.