≡ Menu

command tar

HowTo: Linux Install LibreOffice

How do I install newly released LibreOffice under Debian, Ubuntu or Fedora Linux?
[click to continue…]

How do I create a tar file under Linux using command line options?
[click to continue…]

How can I keep out certain files when creating a tarball? For example:


How do I exclude zyz and abc file while using a tar command?
[click to continue…]

List the contents of a tar or tar.gz file

Q. How do I list the contents of a tar or tar.gz file?

A. GNU/tar is an archiving program designed to store and extract files from an archive file known as a tarfile. You can create a tar file or compressed tar file tar. However sometime you need to list the contents of a tar or tar.gz file on screen before extracting the all files.

Task: List the contents of a tar file

Use the following command:
$ tar -tvf file.tar

Task: List the contents of a tar.gz file

Use the following command:
$ tar -ztvf file.tar.gz

Task: List the contents of a tar.bz2 file

Use the following command:
$ tar -jtvf file.tar.bz2


  • t: List the contents of an archive
  • v: Verbosely list files processed (display detailed information)
  • z: Filter the archive through gzip so that we can open compressed (decompress) .gz tar file
  • j: Filter archive through bzip2, use to decompress .bz2 files.
  • f filename: Use archive file called filename

Q. How do I open or uncompress .gz extension file under Linux or UNIX computer?

A. The .gz file extension are created using Gzip program which reduces the size of the named files using Lempel-Ziv coding (LZ77). gunzip / gzip is software application used for file compression. gzip is short for GNU zip; the program is a free software replacement for the compress program used in early Unix systems.

Each file is replaced by one with the extension .gz, while keeping the same ownership modes, access and modification times.

To expand i.e. to Unpacking or uncompressing gz files you need to use gunzip program Or gzip -d or zcat program:

Using gunzip command:
$ gunzip file.gz
$ ls file

Using gzip -d command:
$ gzip -d file.gz
$ ls file

If file extension is tar.gz, type the command:
$ tar -zxvf file.tar.gz
Please note that gunzip can currently decompress files created by gzip, zip, compress, compress -H or pack programs.

See also:

How do I use tar command over secure ssh session?
[click to continue…]