Linux+ Automation: Implement Automation Using Shell Scripts
In this lab, you’ll practice creating and debugging shell scripts. When you’re finished, you’ll have the knowledge needed to create your own scripts to run customized shell recipes in bash.
Terms and conditions apply.
Lab info
Lab author
Challenge
Get Started in the Lab Environment
Here are the initial instructions and explanation of the lab environment. Read this while your environment is busy creating itself from nothing. Yes, this violates physics; we know. How fun!
Challenge
Understand Script Files and Elements
Using shell scripts in bash, or any shell, allow you to gain the ability to automate processes and ensure repeatability of events. Working through this challenge, you will learn the purpose of scripts and elements used in the script.
Challenge
Add Logic to the Script
In this challenge, you will start adding logic to the script to determine if the Ubuntu package cache needs updating.
Challenge
Write a Replacement Script to Install Software
Now that your script can determine that the apt cache metadata is out of date, you are able to use this as an alternative installer. Using Debian based systems it is necessary to update the metadata prior to installing software; however, this is a scheduled task on Red Hat based systems. As such, your script is most useful on Debian based distributions such as the Ubuntu lab system. You will now make a copy of the script to allow for the package name to be passed to the script for installing. Again, the script will not carry out the update or the install, but will echo what it would do
Challenge
Install Many Packages
You can install a single package, but not more. You will now add a loop to the script allowing you to install many packages, plus will ensure the package list is correct.
Challenge
Install Many Packages in a Single Execution
The script that you have created will install multiple packages, but for each package installed, a separate installation command is done. This takes incurs extra system time and resources. It would be far more efficient if a single installation is done, and you will implement that in this challenge by creating a list of validated packages.
Challenge
The Last Challenge
Welcome to the final challenge! This is your last chance to experiment in the environment. Clicking Finish Lab will end this little world that flittered into existence just for you.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.
Recommended prerequisites
- Command line experience using Linux
- Be able to edit text files using the vim text editor
- Some familiarity with bash scripting
- Solid programming fundamentals, such as understanding ifs