Question: Directions : Using the CLI, follow the steps of this lab and answer the questions. Please type up your answers in this document with the

Directions: Using the CLI, follow the steps of this lab and answer the questions. Please type up your answers in this document with the requested screen-shot and submit to your instructor by the due date provided on the course home page.

Objective: Learn to use the tar and gzip programs.

Part I Creating a tar file

Create the directory /tmp/tar

Navigate to the /tmp/tar directory and using redirection and the cal command, create a log file for each calendar month.

For January, the command would be: cal jan 2014 jan.log would have the month of January in it

The following tar command will archive all files into 2014_logs.tar (the archive will have all the month logs you created) tar command: tar -cf 2014_logs.tar *.log (run in the /tmp/tar directory)

Execute ls on the /tmp/tar directory to verify the file was created. If not, verify your typing and that you are in the right directory and try again.

View the contents of the archive with the command tar -tf 2014_logs.tar Question: What is the output of the above command?

Create a backup directory called backup in the /tmp/tar directory (/tmp/tar/backup)

Using cp, Back up your log files to /tmp/tar/backup (just in case you need them again)

Using rm, delete all of the log files you created that exist in /tmp/tar.

Extract the files in the archive using the command tar -xf 2014_logs.tar

Execute ls on the /tmp/tar directory and look for the log files. They should have extracted, if not, attempt the command tar -xf 2014_logs.tar again.

Part II - Zipping archives

Verify that the 2014_logs.tar exists in the /tmp/tar directory (use ls). If not present, create it by going through the steps in part I.

Examine the file size of 2014_logs.tar by executing ls -l on the /tmp/tar directory. Question: What is the size of the file?

Execute the command gzip 2014_logs.tar

Examine the directory by running an ls l. (take a screen shot of the output and paste below this line) Question: Is there still a file called 2014_logs.tar? Question: What is the name of the new file? Question: What is the new file's size?

Execute the command gunzip 2014_logs.tar.gz

Examine the contents of the /tmp/tar directory again Question: Does the file 2014_logs.tar.gz still exist?

Question: What command would you use to create a tar ball (tar.gz) directly? (instead of creating the tar then zipping, create the tar and zip at the same time)

Questions:

1. What does tar represent?

2.What is the difference between a tar file and a gz file?

3. In part one you used the tar command with the -xf switches, what do the switches -xf accomplish? (examine the help, info, or man page to answer this)

4. What command syntax did you use to delete the log files in part one?

5. Give a real world example of how or where the tar and gzip program could be used.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!