Home Linux How to Create tar.gz file in Linux

How to Create tar.gz file in Linux

How to create tar.gz file in Linux?

In this tutorial, you will learn how to combine and compress files on the Linux system. It is also called “tarball”. This helps to make an archive and also compress directory in a single command.

Example:

To create tar.gz file on the Linux system execute the following command.

tar -cvzf archive.tar.gz directory_path

where c = create an archive
z = compress archive with gz extension.
v = verbose
f = give file name

For example, we want to make archive of ‘htdocs’ directory. New compressed file name is backup.tar.gz. For that, run the following command.

tar -cvzf backup.tar.gz htdocs/

Extract tar.gz file on Linux

For example, to extract backup.tar.gz file on Linux system, execute below command.

tar -xvzf backup.tar.gz


READ MORE: 17 linux Basic Commands with Examples


That’s it.

LEAVE A REPLY

Please enter your comment!
Please enter your name here