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.

Similar Posts

  • Read System Documentation

    Linux offers lots of commands making it challenging to remember them all without help or documentation. For instance while using the long listing format command you might want to ensure you see all options. You can enter: We can see that by entering ls –help, it directs us to the -a option which will return…

  • Linux Login Methods

    Text Mode vs Graphical In Linux you are able to login using a graphical user interface (gui) or text mode with the command line interface. One would login to a Console a terminal or a graphical emulator, these word are used interchangeably nowdays. The way you login to Linux is determined on the way the…

Leave a Reply

Your email address will not be published. Required fields are marked *