$
Learn Linux handbook
en
XP:0
Quest 98Script-Kiddie
+250 XP

Writing Your First Bash Script

Launch Interactive Terminal for This Quest→No installation required • Runs fully in browser

Concept & Overview

Imagine having a list of 20 tasks that you have to run every single morning. Typing them out manually is tedious and leaves room for typos. In Linux, we bundle commands into a file called a shell script so we can execute them all at once!

- Every script starts with a "shebang" (#!/bin/bash) on the very first line to tell the system which shell interpreter to use to run the file.
- After saving your script, you make it runnable by granting it execute permission via chmod 755 script.sh and then running it with ./script.sh.

Let's automate! Create a file named hello.sh in your home folder. Write #!/bin/bash on the first line and echo "Hello, BashQuest User!" on the second. Grant it run permissions with chmod 755 hello.sh and execute it using ./hello.sh.

Command Syntax Reference

Command / SyntaxDescription
touch hello.shCreate script file
chmod 755 hello.shGrant execution permissions
./hello.shExecute the script in current directory

Verification Objectives

These conditions will be automatically verified when you run commands inside the interactive terminal simulator:

  • ○
    Create script file "hello.sh"
  • ○
    Add shebang and hello message inside script
  • ○
    Make script executable (permissions odd digit)
  • ○
    Run the script using "./hello.sh"

Ready to complete Quest 98?

Test your skills live in the browser terminal with an emulated Linux filesystem, real-time command evaluation, and instant step-by-step hints.