Fundamentals 11 min read

Master Linux Permissions: Complete Guide for Beginners

This comprehensive tutorial explains Linux permission concepts, user classifications, file type symbols, basic read/write/execute rights, numeric and symbolic representations, essential commands like chmod, chown, chgrp, and umask, as well as special permissions such as the sticky bit, providing clear examples and usage tips for effective system administration.

Open Source Linux
Open Source Linux
Open Source Linux
Master Linux Permissions: Complete Guide for Beginners

Understanding Linux Permissions: A Comprehensive Guide for Beginners

1. Linux Permission Concepts

In Linux, permissions control user access to files and directories. Each file and directory has three basic permissions: read (r), write (w), and execute (x). These permissions apply to three classes of users: the file owner (

u

), the owning group (

g

), and others (

o

).

1.1 User Classification

Linux has two types of users:

Superuser (root) : can perform any action without restriction.

Regular user : limited to permitted operations.

Superuser prompt is

#

, regular user prompt is

$

.

1.2 Syntax

su [username]

1.3 Function

Switch user.

2. Linux Permission Management

2.1 File Accessor Categories

User (u) : the owner of the file or directory.

Group (g) : the group that owns the file or directory.

Others (o) : all users other than the owner and group.

2.2 Permission Representation

Permission representation
Permission representation

2.3 File Types

d

: directory

-

: regular file

l

: symbolic link

b

: block device

p

: pipe

c

: character device

s

: socket

2.4 Basic Permissions

Read (r) : view file contents or list directory contents.

Write (w) : modify file contents or create/delete files in a directory.

Execute (x) : run a file or enter a directory.

- : indicates the permission is not granted.

2.5 Permission Value Representations

a) Symbolic notation

Symbolic permission representation
Symbolic permission representation

b) Octal notation

Octal permission representation
Octal permission representation

2.6 Permission Management Commands

The main commands for managing permissions are:

1. chmod command

Change file or directory permissions.

chmod [options] mode file

Examples:

chmod u+rwx file.txt   # give owner read, write, execute
chmod g-w file.txt      # remove write from group
chmod o=rx file.txt    # set others to read and execute only
chmod 755 file.txt      # set permissions to rwxr-xr-x
chmod -R 755 directory # recursively change permissions

2. chown command

Change file or directory owner.

chown [options] owner[:group] file

Examples:

chown user file.txt               # change owner to user
chown user:group file.txt         # change owner to user and group to group
chown -R user:group directory    # recursively change owner and group

3. chgrp command

Change file or directory group.

chgrp [options] group file

Examples:

chgrp group file.txt          # change group to group
chgrp -R group directory     # recursively change group

4. umask command

Set the default permission mask for newly created files and directories.

umask [options] [mask]

Examples:

umask 022   # default permissions become 755 for directories, 644 for files
umask 077   # new files/directories are accessible only by the owner (600/700)

In Linux, the umask determines the default permissions by masking bits from the base permissions (666 for files, 777 for directories).

a) How umask works

Default file permission 666 minus umask 022 equals 644 (rw-r--r--). Default directory permission 777 minus umask 022 equals 755 (rwxr-xr-x).

b) Viewing and setting umask

View current umask:

umask

Set umask:

umask 022

c) Permanent umask configuration

Add a line like

umask 022

to the user's shell profile (e.g.,

.bashrc

or

.profile

).

d) Special Cases

umask 000

: new files get maximum permissions (666/777) – not recommended for security.

umask 077

: new files/directories are accessible only by the owner (600/700) – suitable for high‑security scenarios.

2.7 Special Permissions (Sticky Bit)

The sticky bit restricts deletion or renaming of files in a directory to the file owner or root, even if other users have write permission.

1. Purpose of the Sticky Bit

Commonly used on public directories such as

/tmp

to prevent users from deleting each other's files. When set, the other‑users execute bit appears as

t

(or

T

if execute is not set).

2. Setting the Sticky Bit

Use

chmod

:

chmod +t directory   # set sticky bit
chmod -t directory   # remove sticky bit

3. Example

Check

/tmp

permissions:

ls -ld /tmp
# drwxrwxrwt 10 root root 4096 ... /tmp

Create a directory with sticky bit:

mkdir mydir
chmod 1777 mydir   # rwxrwxrwt
ls -ld mydir

4. Notes

The sticky bit only applies to directories, not files.

After setting it, other users can modify file contents but cannot delete or move the files.

Proper use of the sticky bit helps protect files in shared directories from unauthorized deletion or movement.

LinuxPermissionschmodchownumaskSticky Bit
Open Source Linux
Written by

Open Source Linux

Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.

0 followers
Reader feedback

How this landed with the community

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