Archiving Files and Directories with Compression

15 minutes
  • 4 Learning Objectives

About this Hands-on Lab

Creating a compressed archive file can be useful for backup purposes. In this hands-on lab, we’re going to make a compressed archive of a directory containing a custom application before upgrading the application to guarantee that we have a copy of the working program.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Create an Archive Directory in the cloud_user Home Directory

First, let’s make sure we’re in our home directory, then create an archive directory and get into it:

mkdir archive
Make the Archive Directory the Current Directory

Change the directory to archive using the cd command:

cd archive
Archive the /opt/myapp Directory as myapp.tar.gz

Use the tar command to create the myapp.tar.gz archive containing /opt/myapp and its contents:

tar -cvzf myapp.tar.gz /opt/myapp
List the Contents of myapp.tar.gz and Redirect It to app.list

Use the tar command to list the contents of myapp.tar.gz:

tar -tf myapp.tar.gz

It looks good, so now let’s run that command again and redirect the output to an app.list file:

tar -tf myapp.tar.gz > app.list

Additional Resources

The development group that our team of administrators supports is ready to implement some upgrades on their system. Before they begin, they have asked that our team create an archive of the custom application in the /opt/myapp/ directory, just in case the upgrade causes any issues or overwrites files unintentionally.

The upgrades are expected to use most of the provisioned disk on the system, so the backup we take will need to be compressed. We need to create a file called myapp.tar.gz in the /home/cloud_user/archive directory.

myapp.tar.gz should be an archive of all files and directories contained under the /opt/myapp directory, and the final file should be compressed with the appropriate utility according to the file extension. Once this is complete, we need to verify that the resulting archive file properly lists the files and directories in the /opt/myapp directory. To prove it, we need to capture a list of the archive's contents, then put it in a file called app.list within the same /home/cloud_user/archive directory.

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.

Get Started
Who’s going to be learning?

How many seats do you need?

  • $499 USD per seat per year
  • Billed Annually
  • Renews in 12 months

Ready to accelerate learning?

For over 25 licenses, a member of our sales team will walk you through a custom tailored solution for your business.


$2,495.00

Checkout
Sign In
Welcome Back!
Thanks for reaching out!

You’ll hear from us shortly. In the meantime, why not check out what our customers have to say about ACG?