File archive is more important for any system administrator.

There are numbers of archive tools used in Linux to archive files for storing with minimum space and for backup of data.

Today, In this article, we will check the three most essential and useful tools to archive files and directories in Linux.

Tool 1 – zip

The zip tool to use compress and decompress the file with file extension “.zip,” it is essential an useful for all system administrator to do day-to-day work.

Create an archive of files using zip

To create an archive of any file use zip command and desired archive file name with “.zip” extension and file name which need to archive, as shown below:

In the above example make a logs.zip archive file for all file under /var/log directory whose having “.log” extension.

Create an archive of a directory using zip

Similarly, the above example, we can use zip to archive directory also by using the “-r” option, as shown below:

Extract zip archive

You can use unzip command to extract the archived file with “.zip” extension, as shown below:

Tool 2 – tar

The tar is another most essential archive tools for system administrators and Linux lovers.

Most of the time, we use the tar archive to keep backup of data.

Create an archive of files using tar

To create archive files using the tar command-line tool you should use “-c” and “-f” option with tar, as shown below:

In the above example, we created logs.tar archive file for all file under the directory “/var/log” whose having “.log” extension.

Option:

-c = use to create an archive file
-f = use to run the command forcibly

Create Archive of directory using tar

To create an archive file for an entire directory using tar command, as shown below:

Extract tar archive file

To extract the tar archive file use tar command with the “-x” option, as shown below:

The option “-x” use to extract the archived file.

Tool 3 – gzip

Gzip is also one of the important tools for the archive. It also supports to take input of data as standard input or through pip and create an archive file.

Create an archive of files using gzip

You can create an archive file using gzip command, as shown below:

Create an archive file of piped data

You can also create an archive file for piped data by using the following command:

Extract “.gz” archive file

You can use the following command to extract “.gz” archive file:

Tar + Gzip tool

The most useful archive tool when you use tar with gzip.

To use both in the single command, you can use tar command with the “-z” option.

Create an archive of files

Create an archive of a directory

Extract an archive file

If You Like What We Do Here On LinuxConcept, You Should Consider:

Stay Connected to: Twitter | Facebook

Subscribe to our email updates: Sign Up Now

 

We are thankful for your support.

Follow me

SATISH KUMAR

I am Satish Kumar, Founder of LinuxConcept. Linux and F.O.S.S enthusiast, love to work on open source platform and technologies.
Follow me