Archiving & Compressing Files
Managing and compressing files is an important administrative task. An archived of a file can be created by using the tar command.
To create an archive the following syntax is used: tar -cvf archivename.tar /files-you-want-to-archive. The options selected will modify the archive produced as follows:
-c – create a new archive
-v – this will create a lable/name for the archive
-f – create a new file
To create an archive a root shell is required

We will create the archive etc.tar in the /etc directory
Check the file creation with the file command…

Now let’s compress the the file using the GNU zip utility and package it up as etc.tar.gz
….and check the creation

We see that it was compressed and the time it was last modified.
Now let’s extract the file to the a newly created subdirectory of etc in the hosts file.

We can recursively list all files in this current directory with ls -R for another view of etc subdirectory contents and the host file

Let’s unzip the etc.tar.gz file…

We have now decompressed the file and nothing else has changed at this point.
