1. Create a new file called hello-world.sh using
touch hello-world.sh 2. Make the script executable by running
chmod +x hello-world.sh 3. Add this code:
#!/bin/bash
echo "Hello World"
Explanation:
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 hello-world.sh Line 2: Uses the
echo command to write Hello World to the standard output. 4. Execute the hello-world.sh script from the command line using one of the following:
./hello-world.sh – most commonly used, and recommended
/bin/bash hello-world.sh
bash hello-world.sh – assuming /bin is in your $PATH
sh hello-world.sh
Ucartz services for this topic
- KVM VPS hosting: NVMe SSD and full root access, with Free Basic Managed Support.
- Unmanaged dedicated servers: full root access and free IPMI KVM, with Free Basic Managed Support.
- Linux server management: hardening, patching, monitoring and automation for Ubuntu, Debian, RHEL and AlmaLinux.
