Linux gtar Command Tutorial with Examples and Compare with Tar

RSS
FACEBOOK
FACEBOOK
PINTEREST
PINTEREST
LINKEDIN
INSTAGRAM

Linux provides gtar command in order to compress and create tar files. If we are trying to tar a directory and within this directory, there will be a lot of sub-directories and files. We need to tar this directory with tar format. We can use gtar which is an alias of the tar command to create tar archives.

Install For Ubuntu, Debian, Mint, Kali

We can install tar command with the following command.

Install For Ubuntu, Debian, Mint, Kali
Install For Ubuntu, Debian, Mint, Kali

Install Fedora, RedHat, CentOS

We can install tar for Fedora, RedHat, CentOS with dnf or yum command like below.

OR

Create Tar Archive

We can create new tar file by using cvf options like below. We will provide the directory name or path and also provide the newly created archive file with .tar extension. We will tar the directory with the nmap to the nmap.tar

Create Tar Archive
Create Tar Archive

Extract Tar Archive

We can extract a tar archive with the xvf option like below. We will just provide the name of the tar archive which is nmap.tar in this case.

Compress Tar Archive with Gzip

We can create a tar archive which is also compressed by using Gzip compression algorithm. We will just provide the -z option to the default tar creation options. We will create tar.gz gzip compressed archive from the directory nmap in this example.

LEARN MORE  Linux gunzip Command Tutorial with Examples

Compress Tar Archive with Gzip
Compress Tar Archive with Gzip

Compress Tar Archive with Bzip

Bzip is another compression algorithm which can be used to compress tar files to use less storage. We will provide extra -j  option to the xvf like below.

RSS
FACEBOOK
FACEBOOK
PINTEREST
PINTEREST
LINKEDIN
INSTAGRAM