Compress and extract individual files and directories.
Outcomes
Archive a directory tree and extract the archive content to another location.
As the student user on the workstation machine, use the lab command to prepare your environment for this exercise, and to ensure that all required resources are available.
[student@workstation ~]$ lab start software-compressed
Instructions
On the command line, review the contents of the ~/Documents directory in a tree-like format.
[student@workstation ~]$ tree Documents/
Documents/
└── Exercise
├── Debrief.doc
├── Questions
├── Solutions
├── Summary.txt
└── presentation.pptIn the Documents directory, create a back up of the Exercise directory.
Use the tar command with the --xz option for the compression.
Save the archive file as exercise.tar.xz in the /tmp directory.
[student@workstation ~]$cd /home/student/Documents[student@workstation Documents]$tar --create --xz \ --file /tmp/exercise.tar.xz Exercise/
Create the back up again, and this time, include the ~/Desktop/Notes.txt file.
Use the relative path to the Desktop directory as an argument of the tar command.
Replace the exercise.tar.xz file with the new back up.
[student@workstation Documents]$ tar --create --xz \
--file /tmp/exercise.tar.xz Exercise/ ../Desktop/Notes.txt
...output omitted...Create the /home/student/Backup directory and change to that directory.
[student@workstation Documents]$mkdir ~/Backup[student@workstation Documents]$cd ../Backup/[student@workstation Backup]$
Extract the /tmp/Exercise.tar.xz file to the Backup directory.
Review the contents of the Backup directory.
Extract the /tmp/Exercise.tar.xz file to the Backup directory.
[student@workstation Backup]$ tar --extract --xz \
--file /tmp/exercise.tar.xzReview the contents of the Backup directory.
[student@workstation Backup]$ tree
.
├── Desktop
│ └── Notes.txt
└── Exercise
├── Debrief.doc
├── Questions
├── Solutions
├── Summary.txt
└── presentation.pptReturn to the student user home directory.
[student@workstation Backup]$ cd
[student@workstation ~]$Using the GNOME Files application, create the MyNotes.zip compressed file of the Backup directory.
Use password protection and set RedHat123! as the password.
Open the Files application.
Right-click the Backup directory and click .
Set MyNotes as the name and select the format with the icon from the drop-down list.
Set RedHat123! as the password.
Click .
In the Files application, extract the MyNotes.zip compressed file.
Use RedHat123! as the password.
Double-click the MyNotes.zip file.
The Files application prompts for the compressed file password.
Use RedHat123! as the password.
Click .
On the command line, verify that the MyNotes directory contains the expected content.
[student@workstation ~]$ tree MyNotes
MyNotes
└── Backup
├── Desktop
│ └── Notes.txt
└── Exercise
├── Debrief.doc
├── Questions
├── Solutions
├── Summary.txt
└── presentation.ppt
5 directories, 4 files