Most Popular Tools to Archive Files and Directories in Linux

September 20, 2019

Comments

Adsense

Adsense

Adsense

Adsense

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:

# zip logs.zip /var/log/*.log

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:

# zip -r logs.zip /var/log

Extract zip archive

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

# unzip logs.zip

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:

# tar -cf logs.tar /var/log/*.log

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:

# zip -cf logs.tar /var/log

Extract tar archive file

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

# tar -xf logs.tar

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:

# gzip -k apache_access.log

Create an archive file of piped data

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

# cat /var/log/messages | gzip > messages.gz

Extract “.gz” archive file

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

# gunzip apache_access.log.gz

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

# tar -czf logs.tar.gz /var/log/*.log

Create an archive of a directory

# zip -czf logs.tar.gz /var/log

Extract an archive file

# tar -xzf logs.tar.gz
Satish Kumar

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.

Adsense

Adsense

Adsense

Adsense

Adsense

Adsense

Adsense

Adsense

Adsense

Related Posts

How to add swap space on Ubuntu 21.04 Operating System

How to add swap space on Ubuntu 21.04 Operating System

The swap space is a unique space on the disk that is used by the system when Physical RAM is full. When a Linux machine runout the RAM it use swap space to move inactive pages from RAM. Swap space can be created into Linux system in two ways, one we can create a...

How to add swap space on Ubuntu 20.04 Operating System

How to add swap space on Ubuntu 20.04 Operating System

The swap space is a unique space on the disk that is used by the system when Physical RAM is full. When a Linux machine runout the RAM it use swap space to move inactive pages from RAM. Swap space can be created into Linux system in two ways,...

0 Comments

0 Comments

Submit a Comment

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

4 × 4 =

News & Updates

Join Our Newsletter

Adsense

Adsense

Adsense

Adsense