0/1 Lessons

Introduction to Linux Server Operating Systems

• 30min

0 / 3 lessons complete

Linux Server Installation and Lab Setup

• 23min

0 / 6 lessons complete

Working with the Linux Command Line Interface

• 1hr 30min

0 / 12 lessons complete

User and Group Management

• 44min

0 / 7 lessons complete

Linux Storage

• 30min

0 / 6 lessons complete

Linux Administration Basics

• 53min

0 / 8 lessons complete

Linux Networking

• 47min

0 / 8 lessons complete

Course Conclusion

• 5min

0 / 1 lessons complete

Creating Executable Bash Scripts


Q&A (0)

Resources (0)

Saving Progress...


There are no resources for this lesson.

In this lesson, you will learn how to create executable bash scripts in Linux. Bash scripts are a powerful tool for automating tasks, running a series of commands, and managing system operations. By the end of this lesson, you will understand the basics of script creation, how to make a script executable, and how to run it. This skill is vital for anyone looking to streamline their workflow in a Linux environment.

Understanding Bash Scripts

A Bash script is a plain text file containing a series of commands that the bash shell can execute. These scripts can range from simple to complex, depending on the tasks they are designed to perform. The beauty of bash scripts lies in their ability to automate repetitive tasks, thereby saving time and reducing the potential for human error.

Creating a Basic Bash Script

To create a bash script, you first need a text editor. For beginners, nano is a user-friendly choice. Let’s create a simple script that prints "Hello, World!" to the terminal. Open your terminal and type:

nano hello_world.sh

This command opens the nano editor and creates a file named hello_world.sh. In the editor, write the following script:

echo "Hello, World!"

The first line, #!/bin/bash, is called the shebang. It tells the system that this script should be run in the bash shell. The second line is the command that prints "Hello, World!" to the screen.

Making the Script Executable

After saving the file, the script is not yet ready to run. You need to make it executable. To do this, use the chmod command:

chmod +x hello_world.sh

This command changes the script’s permissions, allowing it to be executed.

Running the Bash Script

Now that your script is executable, you can run it directly from the terminal. Navigate to the directory where your script is located and type:


You should see "Hello, World!" printed in your terminal.

Verifying Your Script Works

To verify that your script runs correctly, you can look for the output in the terminal. After running the ./hello_world.sh command, if you see "Hello, World!" displayed, your script is working correctly.

In the video above we also added a sub expression operator to the echo command like so:

echo "Hello, world! The current date is $(date)"

That's all we have to do in this lesson! See you in the next one..

Server Academy Members Only

Sorry, this lesson is only available to Server Academy Full Access members. Become a Full-Access Member now and you’ll get instant access to all of our courses.

0 0 votes
Lesson Rating
Notify of
profile avatar
Inline Feedbacks
View all comments