What you need to know about HELLO WORLD Bash Script
Just like in other programming languages, "Hello world" is often the first line of code written by programmers when starting to learn Bash scripting.
Here you will find out:
- about "Hello world" Bash script
- how to write "Hello world" shell script
- what the structure of "Hello world" script is
- what mistakes when writing a Bash script "Hello world" are
Are you ready? Let's read!
What is a "Hello world" Bash script?
"Hello world" is the first program you will write in Bash shell scripting. This program will display the famous "Hello world!" phrase to any user that runs the Bash script. There are many different ways to write a Bash script that will display "Hello World!" to users.
Steps to writing a "Hello world" shell script
You can either use the VI or NANO text editor to write your first "Hello world" shell script in Bash. The example below shows you how to write a "hello world" script using the NANO text editor.
- Step 1: Create a new file and save it as "hello.sh"

- Step 2: Enter the following line of code

- Step 3: Run your script
There are different ways to run this script, and they are highlighted below.
The simple way:- bash hello.sh
OR - ./hello.sh
OR - sh hello.sh
The advanced method:- chmod +x hello.sh
- bash hello.sh
The structure of a "Hello world" script
This script consists of just two lines, and that’s all. However, sometimes it may have up to three lines if comments are included:
Anything was written after the hash (#) sign is treated as a comment and is ignored by the system while running the script.
So, the "Hello world" script has two lines, primarily. The first line tells the shell to execute the following command(s)/code(s) as a Bash script, while the second line is the actual command to be printed on display when a user runs the script.
Mistakes when writing a Bash script "Hello world"
Here are some common errors that may interrupt the successful output of your Bash script "Hello world":
- If you are editing the script on Windows, this will introduce some characters at the end of your script, and Bash cannot read these characters; thus, you may get the following output: command not found. However, this error can be solved using the dos2unix program; this program edits the file inline. Example:

- Some people may forget to apply to execute permissions, which may return the following output: ./hello-world.sh: Permission denied. Fix this by writing

- Bash and sh are unique shells; thus, using sh./hello-world.sh can return an error output. It is advisable to rely on the script’s shebang (#!) when writing Bash or sh. Commonly, most people use #!/usr/bin/env instead of trying to direct a path to Bash.
How to open Linux files from Windows
It is possible to access and view your Linux files while booted to Windows on a dual-boot PC or virtual machine. This is possible using DiskInternals Linux Reader, a superb freeware application that is designed to read Ext2/3/4 partitions.




Related articles
- About a bash date command
- How to Access Linux Ext2 or Ext3 on Windows
- How to Access Ext4 from Windows
- How to Mount Ext4 on Windows for Free
- Mount Linux Drive on Windows for Free
- Bash Script: All You Need to Know
- An Algorithm: How to Create Bash While Loop
- Linux Shell: What You Need to Know at First
- 5 Basic Shell Script Examples for Your First Script
- Bash: How to Check if the File Does Not Exist
- Bash Time Command on Linux
- How to use bash get script directory in Linux
- How to Check Bash String Equality
- How to Use Linux Wait Command
- Bash: How to Loop Through Files in Directory
- 20 Examples of Bash Find Command
- Bash Cat Command in Examples
- Bash Script SSH: How to Use It
- Bash: A Script For User Input
- Linux ZSH: the basic you need to know
- Basic of Grep in Linux Shell Script
- Shell Script Cut: Basic You Need to Know
- Bash: How to Check if String Not Empty in Linux
- Bash: how to split strings in Linux
- Linux: Sudo in Bash Scripts
- A Linux bin/bash Shell
- Linux: New Line in Shell Script
- Linux: Bash String Ends With
- Linux: Bash Printf Examples
- Linux: Bash First Line
- Linux: $0 in a Shell Script
- Linux: A Bash Startup Script
- Linux: Write a Shell Script
- Shell Script: Replace String in File
- A crontab service shell script
- Bash and sh: is there any difference
- A Bash Dirname Command
- Linux: A Bash Source Command
- A Bash to Loop through Lines in File
- Linux: A Bash Linter
- A Bash Nested Loop
- A Bash Test Command
- Use a Shell Script to Send an Email
- A Bash Status of Last Command
- Linux: A Bash Basename Command
- Using Bash to Write to a File
- About Bash Language
- Bash for Loop in One Line
- AWK in a Bash Script
- Learn about useful bash scripts
- Learn about systemd startup script
- About chaining bash commands
- Learn about a bash error code
- Using a bash tee command
- About a bash export command
- Learn about a bash wait command
- Arch Linux install script
- About advanced bash scripting
- To run a shell script in Dockerfile
- About a bash UNTIL loop
- Learn about C shell script
- Learn about Korn shell scripting
- Using /usr/bin/env command
- Whether bash waits for command to finish
- Using bash if 0
- Using && in an IF statement in bash
- If you want to run shell script in background
- The disk you inserted was not readable by this computer error
- Learn about SFTP in bash scripting
- Learn to run Perl script in Linux
- Examples of using the Expect
- Copy command in shell scripts
- Shell script usage
- Install Oracle Database
- Here is everything you need to know about Bash for Windows
- Guide in Pictures
- How to Use Shell Script Sleep Command
- A Bash Multiline Command
