🛡️

Linux Permissions Overview week 4

Oct 28, 2025

Overview

This lecture covers Linux file and directory permissions, their meaning, manipulation using commands like chmod, octal representation, and how default permissions are set using umask.

Linux Permissions Structure

  • Linux permissions are inherited from UNIX, designed for multi-user systems.
  • Permissions are viewed with ls -l, showing file type and permission flags.
  • The permission string is organized as: user, group, and other (in that order).
  • The first character indicates file type: - for files, d for directories.

Permission Flags and Their Meaning

  • Permission flags: r (read), w (write), x (execute).
  • A dash (-) means the permission is not granted.
  • User is the file owner, group is a set of users, others are everyone else.
  • Read: view file contents; Write: modify file; Execute: run as a program/script.

Managing Permissions (Files)

  • Owner can change permissions using chmod (change mode).
  • Add permission: e.g., chmod o+r filename gives read access to others.
  • Remove permission: e.g., chmod o-w filename removes write access for others.
  • Read access allows users to copy (but not change) files.
  • Write access lets users edit files; execute is needed to run scripts.

Managing Permissions (Directories)

  • Read on directory allows listing files within.
  • Write on directory allows creating, deleting, or renaming files.
  • Execute on directory (pass-through) allows accessing the contents by name, but not listing without read.
  • Lack of execute prevents entry into directory regardless of file permissions inside.

Symbolic and Octal Permission Notation

  • Symbolic notation uses letters: u (user), g (group), o (other), a (all), and symbols +, -, =.
  • Octal notation uses 3 digits: each digit (0–7) represents permissions for user, group, and others (e.g., 640).

Default Permissions and umask

  • New files are assigned permissions based on umask.
  • Umask subtracts permissions from the system default.
  • To determine umask: subtract desired permissions from 7 for each category.
  • umask 137 leads to default permissions of 640.

Key Terms & Definitions

  • User — Owner of the file or directory.
  • Group — Set of users sharing common permissions.
  • Other — All users not in user or group.
  • Read (r) — Permission to view contents.
  • Write (w) — Permission to modify contents.
  • Execute (x) — Permission to run file or enter directory.
  • chmod — Command to change file or directory permissions.
  • umask — Sets default permissions for new files/directories.

Action Items / Next Steps

  • Practice using ls -l, chmod, and umask commands.
  • Experiment with changing permissions using both symbolic and octal notations.
  • Review how permissions work differently for files and directories.