Course contentsShow
← Security
Lesson 1423 of 3,05229. Operating System Security - HardeningFree lesson

Linux File Permissions and Ownership

Mastering rwx permissions, user/group/other model, and chmod/chown commands for access control.

Linux File Permissions and Ownership

What You'll Learn

You'll master the rwx permission model, the user/group/other access control structure, and the chmod/chown commands that enforce least privilege at the filesystem level.

The Three-Layer Access Model

Linux protects files through three permission sets:

  • User (u): The file's owner
  • Group (g): Members of the file's assigned group
  • Other (o): Everyone else on the system

Each layer gets three permission types: read (r), write (w), and execute (x).

Think of it like a building with three security checkpoints: the owner has a master key, group members share department access cards, and others might only enter the lobby.

Reading Permission Strings

When you run ls -l, you see something like:

-rw-r--r--  1 alice developers 2048 Jan 15 10:00 config.txt

Breaking down -rw-r--r--:

  • First -: file type (not a directory)
  • rw-: Owner (alice) can read and write
  • r--: Group (developers) can only read
  • r--: Others can only read

Changing Permissions with chmod

Symbolic mode:

chmod u+x script.sh          # Add execute for user
chmod go-w secrets.conf      # Remove write from group/other
chmod u=rw,go= private.key   # Set user to rw, remove all group/other

Numeric mode (octal):

chmod 600 credentials.txt    # rw------- (owner only)
chmod 750 /opt/app/bin       # rwxr-x--- (user full, group read/execute)

Changing Ownership with chown

chown alice:developers app.conf    # Change owner and group
chown -R webserver:www-data /var/www  # Recursive ownership change

Key Takeaway: Linux file permissions implement least privilege through a three-tier rwx model (user/group/other), controlled via chmod for permissions and chown for ownership—foundational access control for system hardening.