</>
Skip to content
Bash lessons (24/29)

Bash — Permissions

Permission types

PermissionSymbolNumeric
Readr4
Writew2
Executex1

Viewing permissions

ls -la
# -rw-r--r-- 1 user group 1234 Aug 23 10:00 file.txt
#  ^^^^^^^^
#  Owner Group Others

Changing permissions

chmod +x script.sh      # Add execute
chmod -w file.txt       # Remove write
chmod u+w file.txt      # Add write for user
chmod g+r file.txt      # Add read for group
chmod o-x file.txt      # Remove execute for others

Numeric permissions

chmod 755 script.sh     # rwxr-xr-x
chmod 644 file.txt      # rw-r--r--
chmod 700 private.sh    # rwx------
chmod 666 public.txt    # rw-rw-rw-
chmod 777 everything.sh # rwxrwxrwx

Ownership

chown user:group file    # Change owner
chown -R user:group dir  # Recursive
chgrp group file         # Change group only

Special permissions

chmod u+s program        # Setuid
chmod g+s directory      # Setgid
chmod +t directory       # Sticky bit

Mini Practice

Write Bash code that:

  1. Views file permissions
  2. Changes permissions with symbolic mode
  3. Changes permissions with numeric mode
  4. Changes file ownership

Up Next

In the next lesson, you'll learn about Processes — managing processes in Bash.

Related Topics

Frequently Asked Questions about Permissions

What is Permissions in Bash?

Permissions is a fundamental concept in Bash. This lesson explains it step by step with clear examples, making it easy for beginners to understand.

How do I learn Permissions?

Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Permissions.

Why is Permissions important in Bash?

Permissions is essential for Bash development. Understanding this concept will help you write better code and solve real-world problems more effectively.