Using Temporary Files and Directories in Linux

45 minutes
  • 3 Learning Objectives

About this Hands-on Lab

In this hands-on lab, we will practice working with temporary files and directories. Knowing how and when to use temporary files and directories for transient and temporary storage is a good skill to have as a systems administrator.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Retrieve and Unpack the Archive
  1. Change to the /tmp directory.
    cd /tmp
  2. Use wget to retrieve the file.
  3. Unpack the archive.
    tar xf sosreport-ip-10-0-1-11-2019-03-22-wxoxhnk.tar.xz
Create a Temporary File from the Directory Listing
  1. Create a temporary file from a recursive directory listing of the archive folder.
    ls -R sosreport-ip-10-0-1-11-2019-03-22-wxoxhnk/ >> $tmp_file
Move the `version.txt` File to a More Persistent Temporary Directory
  1. Move the version.txt file to /var/tmp.
    mv sosreport-ip-10-0-1-11-2019-03-22-wxoxhnk/version.txt /var/tmp

Additional Resources

You have been asked to retrieve a single file from an archive and place that file in a temporary directory that will persist through a reboot. The file you need to retrieve is version.txt, and the path to the archive is Use wget to retrieve the archive, and unpack it in a temporary directory that will be cleared upon the next system boot.

You will then need to create a temporary file from a recusive listing of the archive folder.

Finally, place version.txt in a temporary directory that will persist through a system boot.

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?