Tar.gz archives

Tar is a popular file archiver in Unix / Linux systems. Tar is often used together with gzip or BZip2 archivers, as they complement each other perfectly: Tar cannot compress files, only collect them into one archive, and GZip and BZip2 cannot compress multiple files at the same time, so if you need to pack multiple files and directories, they are first collected into one uncompressed archive using Tar, which will save some of their attributes, such as access rights, and then this archive is compressed using GZip or BZip2. The whole process is started by one console command, about which further.

How to pack a tar archive.gz and tar.BZ2 on Ubuntu, Debian, CentOS 

One tar cfvz archive.tar.gz *.php 

where tar-command, cfvz-keys, archive.tar.gz is the name of the future archive,*.php – a list of files to be archived. 

The list can be replaced with a directory that you want to pack the whole, for this specify the path to it, absolute or relative 

One tar cfvz archive.tar.gz /forpack 

Now more about the keys 

– C-command that means ” create archive» 

– f – command to pack files and directories into one archive file 

– v-enables visual display of the archiving process 

-z — use GZip compression 

You can also use bzip2 compression. To do this, use the-j key instead of-z. 

In this case, the command is to pack the tar.bz2 will look like this 

tar cfvj archive.tar.bz2 /forpack 

Instead of GZip and BZip2 you can use other archivers, you just need to choose the appropriate key. 

You can use the –exclude key to exclude a specific directory or file from the archive. 

First, go to the desired directory, then use the following command: 

  • tar cfvz wp-content.tgz wp-content –exclude=wp-content/updraft –exclude=wp-content/uploads –exclude=wp-content/cache 
  • Here we pack the /wp-content/ directory on WordPress, excluding the Updraft wp-content/updraft section, the wp-content/uploads Download section and the wp-content/cache. 
  • An important point is to avoid errors by not specifying a slash / at the end of the path of the directory to be excluded. 

How to unpack tar archive.gz and tar.BZ2 Ubuntu, Debian, CentOS 

To unpack the tar archive.gz or tar.bz2, in the command you need to replace -C with-x, and specify the path to the archive, absolute or relative 

The command to extract the archive to the current directory looks like this 

tar xfvz archive.tar.gz 

With the-C key you can specify the path where you want to unpack the archive 

archive.tar.bz2 -C /var/www 

Viewing tar archives on Linux 

You can use the-t switch to view the contents of the archives 

tar-tf archive.tar.bz2 

A list of files and directories in the archive will be displayed. When you add the-v key, you will also see detailed service information about access rights, file sizes, and more. 

The files with the tar extension.gz is created in a gzip application (short for GNU Zip) that uses the DEFLATE compression algorithm. In most cases, it is used in Unix systems, in Which this format is a standard extension for archives. Most often, these archives contain the source code of applications, less often-documents and images. This is because the files compressed with this algorithm take up little disk space. Opens tar.gz any archiver.  

Than open a file with the tar extension.gz? 

7-zip is a free application for creating, viewing and unpacking archives. It has a simple and intuitive interface. First of all, it is focused on working with 7zip extensions. Supports working from the command line, as well as the integration into the shell in system. 

Zipeg is a free application for working with archives. It only supports viewing and extracting. Together with this program you can view more than 20 archive formats, including tar.gz. it has a simple and pleasant interface, which is easy to understand. Image preview is supported. It is also possible to specify a permanent path to the place of unpacking, the application will not ask for it. 

Leave a Reply

Close Menu