In linux
In computing tar (derived from tape archive) is both a file format and the name of a program used to handle such files.
$ tar cvf archive_name.tar dirname/
1.3 Creating a tarred file that is compressed with bzip
; tar
(Tape ARchive) is file format and name of a program used to simply combine a few files into a single file, for easy storage and distribution. (.zip and .rar in window)In computing tar (derived from tape archive) is both a file format and the name of a program used to handle such files.
- *.tar
*.tgz
is equivalent to *.tar.gz (gzip)
*.tbz
and *.tb2
are equivalent to*.tar.bz2 (bzip)
*.taz
is equivalent to *.tar.Z
*.tlz
is equivalent to *.tar.lz
*.txz
is equivalent to *.tar.xz
A tar file or compressed tar file is commonly referred to as a tarball
Note: A ".tar" file is not a compressed files, it is a collection of files within a single file uncompressed. If the file is a .tar.gz ("tarball") or ".tgz" file it is a collection of files that is compressed. If you are looking to compress a file you would create the tar file then gzip the file.
1. Creating an archive using tar command :
1.1 Creating a tar file:$ tar cvf archive_name.tar dirname/
- The letter
c
means "create archive". - The letter
v
means "verbose", which tellstar
to print all the filenames as they are added to the archive. - The letter
f
tellstar
that the name of the archive appears next (right after these options).
1.2 Creating a tarred file that is compressed with gzip
$ tar cjzf archive_name.tgz dirname/
'z' means "compress this archive with gzip1.3 Creating a tarred file that is compressed with bzip
$ tar cvjf archive_name.tbz dirname/
'j' means "compress this archive with bzip
2. Extracting (untar) an archive using tar command
2.1 Extract a *.tar archieve
$ tar xvf archieve_name.tar
x – extract files from archive
2.2 Extract a gzipped tar archive ( *.tgz )
2. Extracting (untar) an archive using tar command
2.1 Extract a *.tar archieve
$ tar xvf archieve_name.tar
x – extract files from archive
2.2 Extract a gzipped tar archive ( *.tgz )
$ tar xvzf archieve_name.tgz
2.3 Extracting a bzipped tar archive ( *.tbz )
$ tar xvjf archieve_name.tbz
3. Listing an archive using tar command
3.1 View the tar archive file
$ tar tvf archive_name.tar3.2 Extract a gzipped tar archive ( *.tgz )
$ tar tvzf archieve_name.tgz