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

Running Scripts

In this page:

  1. Running Scripts

Running Scripts

A Bash script is run either by passing it to the bash interpreter directly, or by making it executable and running it as its own program. bash script.sh always works regardless of permissions. Running it directly as ./script.sh requires execute permission on the file first.

Note: bash script.sh works even without execute permission, since you're invoking bash explicitly.

Example: Running Scripts

bash
# Run with the interpreter directly
bash script.sh

# Or make it executable and run it directly
chmod +x script.sh
./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.