System Administration

Linux File Permissions Cheatsheet

Master Linux file permissions with comprehensive coverage of file types, permission modes (rwx), numeric notation, chmod/chown commands, and common permission patterns.

Understanding file permissions is crucial for VPS security. Use our performance dashboard to track server metrics, explore secure VPS providers, and compare security features across different hosting options.

#linux #permissions #chmod #chown #sysadmin #security
Sign In to Download

Free account required

i

Permission Format

View file permissions using the ls -la command. Learn more in our Linux Commands cheatsheet.

-rwxr-xr--  file.txt
File Type
- (regular file)
Owner
rwx (read, write, execute)
Group
r-x (read, execute)
Others
r-- (read only)

File Types

The first character in the permission string indicates the file type. For deeper understanding of Linux file systems, see our Linux Filesystem cheatsheet.

-

Regular File

Normal files containing data (text, binary, images, etc.)

d

Directory

A folder containing files and other directories

l

Symbolic Link

A link pointing to another file or directory (similar to shortcuts)

b

Block Device

Block-oriented devices (hard drives, USB drives, etc.)

c

Character Device

Character-oriented devices (terminals, serial ports, etc.)

p

Named Pipe (FIFO)

Special file for inter-process communication

s

Socket

Special file used for inter-process communication

Permission Modes

File permissions are grouped into three categories: Owner, Group, and Others. Each can have Read, Write, and Execute permissions.

Permission Letters

r
Read

View file contents or list directory contents

w
Write

Modify file contents or add/remove files in directory

x
Execute

Run file as program or access directory

Permission Groups

Owner/User

The user who owns the file

Group

Users who are members of the file's group

Others

All other users on the system

Example Breakdown

-rwxr-xr--  1 user group 1234 Jan 10 12:00 file.txt
rwx
Owner can read, write, execute
r-x
Group can read, execute
r--
Others can only read

Numeric Notation (Octal)

Permissions can be represented as three-digit octal numbers, where each digit is the sum of its permission values.

Permission Values

4
Read (r)
2
Write (w)
1
Execute (x)

Common Numeric Permissions

0 --- No permissions
1 --x Execute only
2 -w- Write only
3 -wx Write and execute (2+1)
4 r-- Read only
5 r-x Read and execute (4+1)
6 rw- Read and write (4+2)
7 rwx Read, write, and execute (4+2+1)

Example

754 = rwx r-x r--
7 (Owner): Read, Write, Execute
5 (Group): Read, Execute
4 (Others): Read only

chmod Commands

The chmod command changes file permissions. You can use symbolic or numeric notation. For security-focused examples, check our Linux Hardening cheatsheet.

Symbolic Mode

Give owner execute permission

$ chmod u+x file.txt

Remove write permission from group

$ chmod g-w file.txt

Add read permission for others

$ chmod o+r file.txt

Set exact permissions for all

$ chmod a=rx file.txt

Multiple changes at once

$ chmod u+x,g-w,o-r file.txt
Symbolic notation:
u = user/owner, g = group, o = others, a = all
+ = add permission, - = remove permission, = = set exact permission

Numeric Mode

Set permissions to 755 (rwxr-xr-x)

$ chmod 755 file.txt

Set permissions to 644 (rw-r--r--)

$ chmod 644 file.txt

Set permissions to 600 (rw-------)

$ chmod 600 file.txt

Set permissions to 777 (rwxrwxrwx)

$ chmod 777 file.txt

Recursive Changes

Change permissions recursively for directory

$ chmod -R 755 /path/to/directory

Make all files readable by everyone

$ chmod -R a+r /path/to/directory

chown Commands

The chown command changes file ownership (user and group).

Change owner only

$ chown username file.txt

Change owner and group

$ chown username:groupname file.txt

Change group only

$ chown :groupname file.txt

Or use chgrp groupname file.txt

Change ownership recursively

$ chown -R username:groupname /path/to/directory

Copy ownership from another file

$ chown --reference=ref_file.txt target_file.txt

Change ownership with verbose output

$ chown -v username file.txt
Note: The chown command typically requires root privileges (sudo).

Common Permission Patterns

Here are the most commonly used permission combinations for different use cases:

755 rwxr-xr-x
Most Common

Directories & Executable Scripts

Owner can read, write, execute. Group and others can read and execute. Perfect for directories and scripts.

644 rw-r--r--
Standard Files

Regular Files

Owner can read and write. Group and others can only read. Standard for text files, HTML, CSS, etc.

600 rw-------
Private

Private Files

Only owner can read and write. Used for sensitive files like SSH keys, configuration files with passwords. Learn more about securing SSH in our OpenSSH Server Hardening guide.

700 rwx------
Owner Only

Private Directories & Scripts

Only owner can read, write, and execute. Used for private scripts and personal directories.

666 rw-rw-rw-
Shared Files

Shared Writable Files

Everyone can read and write. Use with caution. Good for temp files or collaboration spaces.

777 rwxrwxrwx
Security Risk

All Permissions

Everyone can read, write, and execute. Avoid using this! Major security risk except for very specific temporary testing.

444 r--r--r--
Read-Only

Read-Only Files

Everyone can read, nobody can write. Good for protecting important files from accidental modification.

Security Best Practices

  • • Use 755 for directories and executable scripts
  • • Use 644 for regular files (HTML, CSS, images)
  • • Use 600 for sensitive files (SSH keys, config with passwords)
  • • Avoid 777 - it's a major security vulnerability
  • • Never use 666 or 777 in production environments
  • • Regularly audit file permissions with ls -la

For comprehensive server security practices, see our Linux Hardening and OpenSSH Hardening guides.

Secure Your VPS Deployment

Proper file permissions are crucial for VPS security. Find reliable VPS providers with excellent security features and performance benchmarks.

Use our performance dashboard to monitor server metrics, compare VPS providers for security features, and explore our server tools for diagnostics.