Learning Permissions in Linux

Interactive File Permissions Display

Enter a permission number (e.g., 755) to see how Linux file permissions work

Quick Reference Guide

Permission Numbers

  • 4 = Read (r)
  • 2 = Write (w)
  • 1 = Execute (x)
  • 0 = No permissions (-)

Common Combinations

  • 7 = Full (rwx)
  • 6 = Read & Write (rw-)
  • 5 = Read & Execute (r-x)
  • 4 = Read Only (r--)

Example: chmod 755

  • 7 (4+2+1) = rwx for Owner
  • 5 (4+0+1) = r-x for Group
  • 5 (4+0+1) = r-x for Others

Common Permission Patterns

Calculate Linux File Permissions

LINUX File Permissions
drwxr-xr-x2userstaff4096Aug 18 07:20 PMexample
User Permissions (read, write, execute)

These are the permissions for the file owner. The owner can:• Read: View file contents, list directory contents• Write: Modify files, create/delete files in directory• Execute: Run programs, access directory contents

Group Permissions (read, execute)

These apply to all users in the file's group. Group members can:• Read: Access file contents as a group member• Execute: Run programs as a group member

Others Permissions (read, execute)

These apply to all other users on the system. Others can:• Read: View file contents (public access)• Execute: Run programs (public execute access)

File Metadata

• Links: Number of hard links to the file (2)

• Owner: Username of the file owner (user)

• Group: Group name assigned to the file (staff)

• Size: File size in bytes (4096)

• Date: Last modification time (Aug 18 07:20 PM)

Read Permission (r)

Allows viewing file contents
Numeric value: 4

Write Permission (w)

Allows modifying file contents
Numeric value: 2

Execute Permission (x)

Allows running the file
Numeric value: 1

Real-world Permission Examples

Common scenarios and their recommended permissions

Web Server Files

Typical permissions for web files:

  • HTML/CSS files: 644 (rw-r--r--)
  • Configuration files: 600 (rw-------)
  • Web directories: 755 (rwxr-xr-x)

User Home Directory

Secure home directory setup:

  • Home directory: 750 (rwxr-x---)
  • Private files: 600 (rw-------)
  • Shared files: 644 (rw-r--r--)

Security Tips

  • Never use 777 unless absolutely necessary
  • Keep sensitive files
  • Keep sensitive files restricted to 600
  • Use groups effectively instead of opening permissions to others
  • Remember that execute (x) is needed for directories to be accessible

Common Mistakes to Avoid

  • Using 777 unnecessarily:
    This gives everyone full access and poses security risks
  • Incorrect directory permissions:
    Directories need execute (x) permission to be accessed
  • Exposing sensitive files:
    Configuration files should be restricted from group/others