• Home
  • Ubuntu 16.04
    • Whats New ?
    • Install JAVA 8
    • Setup LAMP Stack
    • Install LEMP Stack
    • Install Node.js
    • Install Git
    • Move Unity Launcher to Bottom
  • FeedBack
  • Funny Tools
  • Tutorials
    • Linux Distributions
      • CentOS
      • Debian
      • Fedora
      • LinuxMint
    • Monitoring Tools
      • Monit
      • Nagios
      • NRPE
    • Network Services
      • DHCP
      • DNS
      • FTP
    • Databases
      • MySQL
      • MariaDB
      • MongoDB
      • PostgreSQL
      • SQL Server
    • Amazon Web Services
  • Submit Article
  • About Us
TecAdmin.net
  • Home
  • Ubuntu 16.04
    • Whats New ?
    • Install JAVA 8
    • Setup LAMP Stack
    • Install LEMP Stack
    • Install Node.js
    • Install Git
    • Move Unity Launcher to Bottom
  • FeedBack
  • Funny Tools
  • Tutorials
    • Linux Distributions
      • CentOS
      • Debian
      • Fedora
      • LinuxMint
    • Monitoring Tools
      • Monit
      • Nagios
      • NRPE
    • Network Services
      • DHCP
      • DNS
      • FTP
    • Databases
      • MySQL
      • MariaDB
      • MongoDB
      • PostgreSQL
      • SQL Server
    • Amazon Web Services
  • Submit Article
  • About Us
07 January 2018

How to List Archive File Contents in TAR/TAR.GZ/TAR.BZ2

Written by Rahul K. | January 7, 2018
Linux Commands tar

While working with the archive files, sometimes you are required to list archive file contents instead of extract an archive file. Using this you can see the files available in an archive file. Read another tutorial with 18 Linux tar command examples

List Archive File Contents (Quick Commands)

The -t switch is used for list content of a tarball file without extract. Below is the quick commands used to list .tar, .tar.gz, .tar.bz2 and .tar.xz file contents.

tar -tvf archive.tar
tar -ztvf archive.tar.gz
tar -jtvf archive.tar.bz2
tar -Jtvf archive.tar.xz

List .tar File Content

Use -t switch with tar command to list content of a archive.tar file without actually extracting. You can see that output is pretty similar to the result of ls -l command.

tar -tvf archive.tar

[Sample Output]

drwxr-xr-x root/root         0 2018-01-12 11:11 backup/
drwxr-xr-x root/root         0 2018-01-12 11:09 backup/data/
-rw-r----- root/root      1058 2018-01-12 11:09 backup/data/config.ini
-rw-r--r-- root/root        29 2018-01-12 11:11 backup/.htaccess
-rw-r----- root/root       442 2018-01-12 11:08 backup/access.log
-rw-r--r-- root/root         7 2018-01-12 11:09 backup/index.html
lrwxrwxrwx root/root         0 2018-01-12 11:11 backup/config -> data/config.ini

List .tar.gz File Content

We use -z switch for handling .tar.gz files and use -t for the listing of archive file content. See below example to list an archive.tar.gz file contents without extracting the file.

tar -ztvf archive.tar.gz

[Sample Output]

drwxr-xr-x root/root         0 2018-01-12 11:11 html/
drwxr-xr-x root/root         0 2018-01-12 11:09 html/config/
-rw-r----- root/root      1058 2018-01-12 11:09 html/config/config.ini
-rw-r--r-- root/root        29 2018-01-12 11:11 html/.htaccess
-rw-r----- root/root    442488 2018-01-12 11:08 html/access.log
-rw-r----- root/root    263636 2018-01-12 11:08 html/error.log
-rw-r--r-- root/root        17 2018-01-12 11:09 html/index.html
lrwxrwxrwx root/root         0 2018-01-12 11:11 html/config.ini -> config/config.ini

List .tar.bz2 File Content

We use -j switch for handling tar.bz2 files and use -t for the listing of archive file content. See below example to list an archive.tar.bz2 file contents without extracting the file.

tar -jtvf archive.tar.bz2

[Sample Output]

drwxr-xr-x root/root         0 2018-01-12 11:11 www/
drwxr-xr-x root/root         0 2018-01-12 11:09 www/data/
-rw-r----- root/root      1994 2018-01-10 10:19 www/data/config.ini
-rw-r--r-- root/root        29 2018-01-12 11:11 www/.htaccess
-rw-r----- root/root     33442 2018-01-11 10:08 www/index.php
lrwxrwxrwx root/root         0 2018-01-12 11:11 www/config -> data/config.ini

List .tar.xz File Content

We use -J (capital J) switch for handling tar.xz files and use -t for the listing of archive file content. See below example to list an archive.tar.xz file contents without extracting the file.

tar -Jtvf archive.tar.xz

[Sample Output]

drwxr-xr-x root/root         0 2018-01-12 11:11 www/
drwxr-xr-x root/root         0 2018-01-12 11:09 www/data/
-rw-r----- root/root      1994 2018-01-10 10:19 www/data/config.ini
-rw-r--r-- root/root        29 2018-01-12 11:11 www/.htaccess
-rw-r----- root/root     33442 2018-01-11 10:08 www/index.php
lrwxrwxrwx root/root         0 2018-01-12 11:11 www/config -> data/config.ini

Share it!
Share on Facebook
Share on Twitter
Share on Google+
Share on Reddit
Share on Tumblr
Rahul K.
Rahul K.
Connect on Facebook Connect on Twitter Connect on Google+

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

Related Posts

  • How to Create tar Archive excluding some Files & Directories

  • How to Extract .tar.bz2 File using Linux Command

  • 3 Most Popular Tools to Archive Files and Directories in Linux

  • How to Extract .tar.gz File in Linux Command

  • 18 Linux tar Command with Useful Practical Examples

1 Comment

  1. Sanjay Mishra Reply to Sanjay
    January 13, 2018 at 4:03 am

    Thanks… It’s helped me a lot …

Leave a Reply

Cancel reply

Popular Posts

  • How to Install JAVA 8 on Ubuntu 16.04/14.04, LinuxMint 18/17
  • How to Install s3cmd in Linux and Manage Amazon s3 Buckets
  • How to Install AnyDesk on Ubuntu, Debian and LinuxMint (Alternative of TeamViewer)
  • How to Setup Selenium with ChromeDriver on Ubuntu 16.04
  • How to Install MySQL on macOS Sierra and High Sierra
All rights reserved. © 2013-2018 TecAdmin.net. This site uses cookies. By using this website you agree our term and services