← Back to Bash Course | Chapter 9: File Testing & Filesystem | Lesson 11 of 13

File Permissions

In this page:

  1. File Permissions

File Permissions

File permissions control read (r), write (w), and execute (x) access for the owner, group, and others, viewable with ls -l. chmod changes them, either symbolically (chmod u+x file) or numerically (chmod 755 file). Understanding the numeric mode (owner/group/other as three digits) is essential for managing script and file access.

Note: chmod 755 is the common mode for an executable script: owner can read/write/execute, everyone else can read/execute.

Example: File Permissions

bash
#!/bin/bash
touch demo.sh
chmod 755 demo.sh
ls -l demo.sh

chmod u-x demo.sh
ls -l demo.sh

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.