Simple Automation Scripts

Making a script to automate a few commands is actually pretty easy, but seemed really daunting on the first few attempts.

Here is a breakdown to create a simple script, make it executable and run it.  Once you get the hang of this you can create your own customized scripts.


Create a new file with the .sh extension.  While the extension is not necessary for the script to run, it helps you know it’s a script when looking at the file in the directory listing using ls.


This is the first line of the script that tells bash “hey, this is a script!”

# Start Automation Script

Adding comments like this helps to keep track of what the script is doing.

echo “This is an automation script!”

Here’s an example of a command that can be run, really any command run in the terminal can be put into this kind of script.

Your script file should look like this when editing in nano.


# Start Automation Script

echo “This is an automation script!”

Exit and save the file with Ctrl x, confirm you want to save with y and press enter.

chmod +x

Modify the permissions to make the script executable.


Run the script.  This command will run the script but make sure you’re in the same directory as the script.