How to Run Bash Script in Terminal
Fumbani Banda
Feb 02, 2024
Bash
Bash Terminal

This tutorial demonstrates ways to run a bash script in the terminal with the bash
command and by making it executable.
Run Bash Script With the bash
Command
To run a bash script in Linux, you need to use the bash
command and specify the name of the script you want to run.
printf "This is my first script.\n"
printf "This is fun.\n"
Run the script with bash
:
bash script.sh
Output:
This is my first script.
This is fun.
Make Bash Script Executable With chmod
chmod
is used to modify permissions to a file. In our case, chmod
adds the permission to execute for script.sh
. We can now run the script by ./script.sh
.
printf "This is my second script.\n"
printf "This is more fun.\n"
Make the script executable:
chmod +x script.sh
Run the script:
./script.sh
Output:
This is my second script.
This is more fun.
Enjoying our tutorials? Subscribe to DelftStack on YouTube to support us in creating more high-quality video guides. Subscribe
Author: Fumbani Banda