chmod +x
In this page:
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
# 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.
🔒
Chapter Quiz — Complete all 12 topics to unlock
0/12 topics done
Complete these topics first: