Interactive Shell

The Bash shell is commonly used interactively: It lets you enter and edit commands, then executes them when you press the Return key. Many Unix-based and Unix-like operating systems use Bash as their default shell (notably Linux and macOS). The terminal automatically enters an interactive Bash shell process on startup.

Output Hello World by typing the following:

echo "Hello World"
#> Hello World  # Output Example


Non-Interactive Shell

The Bash shell can also be run non-interactively from a script, making the shell require no human interaction. Interactive behavior and scripted behavior should be identical – an important design consideration of Unix V7 Bourne shell and transitively Bash. Therefore anything that can be done at the command line can be put in a script file for reuse.

Follow these steps to create a Hello World script:

  1. Create a new file called
  1. Make the script executable by running [chmod](<>)+x
  2. Add this code:
echo "Hello World"

Line 1: The first line of the script must start with the character sequence #!, referred to as shebang1. The shebang instructs the operating system to run /bin/bash, the Bash shell, passing it the script’s path as an argument.

E.g. `/bin/bash`

Line 2: Uses the [echo](<>) command to write Hello World to the standard output.

  1. Execute the script from the command line using one of the following: