Running your first shell script
We'll break down the components of our first script. If you do not have an editor please refer to the getting started with vim guide below
Getting started with vim

Expected Output 
Permissions of hello.sh script Understanding Linux Permissions
Our first script
#!/bin/bash # Every bash script needs to start with a shebang line
# like the one above this tells the OS what shell to use
echo "Hello World" # The echo command prints to stdout
# Meaning it'll print whatever follows it to the terminalchmod +x hello.sh
# chmod stands for change mode the +x option adds execute permission
# and our argument is the script we created "hello.sh"./hello.sh
# scripts are run by referring to the file
# the `./` means from the current directory that is the starting point
# if the hello.sh script is in the current directory it will run
# the output of the script should be "Hello World"

Last updated
Was this helpful?