Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

Changing Permissions — Symbolic Method

Lesson 30 of 31 in the free Operating System & Linux Programming notes on Siksha Sarovar, written by Rohit Jangra.

Why Two Methods?

chmod accepts both symbolic mode (letters, easy to read) and numeric (octal) mode (compact, scriptable). This lesson covers symbolic; the next covers numeric.

Symbolic Mode Syntax

chmod [who][op][perm] file

Where:

  • whou user/owner, g group, o others, a all (default if omitted).
  • op+ add, - remove, = set exactly.
  • permr read, w write, x execute, X execute only if any execute is already set or it's a directory, s setuid/setgid (with u/g), t sticky.

Common Recipes

GoalCommand
Make script executable for everyonechmod a+x script.sh
Add owner write onlychmod u+w file
Remove world read & writechmod o-rw file
Set owner = rwx, group = r-x, others = nothingchmod u=rwx,g=rx,o= file
Make directory traversable but not listablechmod o=x dir
Add setuid to a binarysudo chmod u+s /usr/local/bin/myprog
Set sticky bit on shared dirchmod +t /shared

You can combine multiple specs separated by commas: chmod u+rwx,g-w,o=r.

Recursive Mode

chmod -R u+w project/ applies to every file inside project/. Beware: blindly adding x to all files turns data files into "executables". Use the capital X:

chmod -R a+rX docs/ — adds read everywhere, but execute only on directories and files that already had any execute bit. Safe for mixed trees.

Changing Owner & Group

  • chown alice file — change owner.
  • chown alice:dev file — owner and group.
  • chgrp dev file — group only.
  • Recursive: chown -R alice:dev project/.

Worked Example

You wrote backup.sh and need:

  • Owner: read, write, execute.
  • Group: read, execute.
  • Others: nothing.

Steps:

  1. ls -l backup.sh — shows current mode, e.g. -rw-r--r--.
  2. chmod u+x,g+x,o-r backup.sh — adds owner/group execute and removes others' read.
  3. ls -l backup.sh — now -rwxr-x---.

Equivalent one-liner using =: chmod u=rwx,g=rx,o= backup.sh.

Symbolic vs Numeric — When to Use Which?

  • Symbolic is great for incremental tweaks (chmod a+x).
  • Numeric is great when you want an absolute mode regardless of the current state (chmod 755).

Common Pitfalls

  • Forgetting the x bit on directories — users complain they can't cd.
  • Setting world-writable on a sensitive file (chmod 777) — security disaster.
  • Recursively forcing x on all files instead of using X.

Summary

  • Symbolic syntax is human-readable and incremental.
  • Combine who, op, and perm to make precise changes.
  • Use -R plus capital X for safe recursive permission updates.