← Back to Bash Course | Chapter 1: Setup & Basics | Lesson 3 of 12

chmod +x

In this page:

  1. chmod +x

chmod +x

chmod +x file adds execute permission to a file, which is required before you can run a script with ./script.sh. Without it, the shell refuses with a "permission denied" error. This is a one-time step needed after creating a new script file.

Warning: Forgetting chmod +x is the most common reason a new script fails to run directly.

Example: chmod +x

bash
# Check current permissions
ls -l script.sh

# Add execute permission for the owner
chmod +x script.sh

# Now it can be run directly
./script.sh

⚠️ Run this command in your terminal.

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.