SUSE Certified Engineer - Shell Scripting

30 minutes
  • 3 Learning Objectives

About this Hands-on Lab

In this hands-on lab, you’ll be creating a user-independent script that will archive a user’s home directory to a location on the system, which you’ll also be setting up. You’ll do a quick proof of concept, and then add other functionality to make the script run properly for all non-root users, as well as add an archive file check and success or failure logging. A colleague attempts to run the script while signed on as root, and experiences an error, so you’ll go over the script, note any issues that are preventing it from running for all users, fix those issues, and then test the results.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Create a Simple Archive Script
  • Prepare your archive directory
  • Set permissions and ownership
  • Create a simple archive script
  • Test your script and troubleshoot if necessary
Add Functionality and Independence to the Script
  • Copy your script to another script
  • Add some additional variables and functionality
  • Make the script more user-independent
  • Add a function check and logging feature
  • Troubleshoot and fix user-dependency issues
Test the Script as Root and Fix Any Issues
  • Run the script and look for any errors
  • Inspect the script for user or directory references
  • Fix a directory reference issue
  • Test and observe the results

Additional Resources

Lab Scenario

In this lab, you're a mid-level Systems Operator who has been tasked with writing a script that archives the cloud_user home directory to an /archive directory with a given name.

Upon testing the script, you realize that it could easily be modified to work for multiple users. You'll make some changes to the script that will make it function for regular users, which includes using an if statement to run a file check and write a log entry indicating success or failure.

You'll then try running this script as root and, when that doesn't work properly, you'll perform a little troubleshooting and implement a fix that makes it work for all users, root and non-root.

What you're going to be going through here is very common in the world of a Systems Admin or Engineer. Automating simple tasks often leads to adding more functionality and making scripts work harder, and all of that saves you more time!

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?