Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I cannot use tar -tz as the solaris version I'm using does not accept the -z option.

I tried something like gunzip file.tar.gz | tar -tv but that only gives:

tar: /dev/rmt/0: No such file or directory

...and unzips the tar.gz to .tar which is undesired. I only want to look inside them without modification.

share|improve this question
add comment

6 Answers 6

up vote 7 down vote accepted

Don't have a Solaris box handy, but wouldn't something like zcat file.tar.gz | tar -tv do the trick? That might need to be gzcat or gunzip -c on Solaris, I'm not sure.

UPDATE: @Riccardo Murri points out that the default behavior of tar on Solaris is NOT to read from stdin (which seems very un-Unixish, but ce la vie), so zcat file.tar.gz | tar -tv -f - is probably what you need.

UPDATE 2: Finally found what looks to be a decent site for Solaris man pages, so I present to you man gunzip and man tar.

share|improve this answer
Thanks for your answer but.. gzcat either displays the contents of all files in the archive, or when given gzat -l it displays only the tar archive in the compressed .gz archive. What I want is really in between: a list of all the files inside the tar archive. Never thought this would be that mind bending. –  dr jerry Aug 5 '11 at 13:56
I think gzip -dc file.tar.gz | tar -tv -f - is the correct invocation; you need the -f - to tell Solaris' tar to read data from STDIN (it's not the default as it is on many Linuxes), and you need to pass -d and -c to to gzip to decrompress to STDOUT. –  Riccardo Murri Aug 5 '11 at 14:08
@Riccardo Murri Thanks. I didn't think about the possible differences in tar behavior, too. I'll update my answer to include the flags you mentioned. –  Hank Gay Aug 5 '11 at 14:32
Solaris man pages are available on Oracle's website: Solaris 10, Solaris 11, other Solaris versions –  Gilles Aug 6 '11 at 0:23
The "un-Unixish" behavior is what the original V7 UNIX tar did. It defaults to reading or writing a tape. That's what the "t" stands for. –  Alan Curry Aug 15 '12 at 15:46
show 2 more comments

Try tar -tvf <filename>.tar.gz (:

share|improve this answer
that gives tar: tape blocksize error unfortunately –  dr jerry Aug 5 '11 at 13:07
You'd probably want to specify a different block size. Try with other archives to see whether the problem persists. –  Daniel Le Aug 5 '11 at 13:29
How would this work in light of the fact that the OP's tar doesn't have a -z option? Does it assume the file is gziped with no flag given? Can you point to documentation on that? –  Caleb Aug 5 '11 at 13:33
It either gives blocksize or checksum error. –  dr jerry Aug 5 '11 at 13:53
add comment

AVFS is a virtual filesystem (based on FUSE) that allows you to see inside archives as if they were directories (amongst others). It's supported in Solaris, but I don't know if there are packages available; you may need to compile from source.

Run mountavfs once and for all (it'll persist until the next reboot; you should put it in your ~/.profile). This creates a view of the whole filesystem rooted at ~/.avfs. Inside this view, every archive has an associated directory whose name has an extra # at the end. This directory contains the contents of the archive.

ls -lR "~/.avfs$PWD/file.tar.gz#"
cp -p "~/.avfs$PWD/file.tar.gz#/path/to/file-to-extract" .
share|improve this answer
add comment

The right answer if you only have the Sun version of tar is:

gzip -dc file.tar.gz | tar -tf -

as given by Riccardo Murri in a comment above. You can use that command on any version of Solaris since the dawn of day.

If you had GNU tar available then you of course wouldn't even be asking the question. I believe that on Solaris 11 that GNU tar is installed by default, however it will be called gtar to distinguish it from the standard Sun version of tar.

If GNU tar for whatever reason is not installed on your Solaris 11 system then you can install it like this:

pkg install //solaris/archiver/gnu-tar

It is somewhat ironic that GNU tar is available now in the default install on Solaris 11 because it has become much less needed : it seems Oracle/Sun has update their own tar so that it now offers compression support (similar to GNU tar) and it can handle troublesome Linux tar files that would previously give an error if you tried to untar with Sun tar.

On Solaris 10 you can hope that your SysAdmin has been kind enough to install the contents of the "Solaris Companion CD" in which case you will find GNU tar in /opt/sfw/bin/gtar. Unfortunately many Solaris SysAdmins take pride in deliberately not installing the packages from Sun (now Oracle) that make a Solaris system "GNU compatible" when they set up a host. Beats me why.

In any case : You should always have GNU tar on your system (at least on <Solaris11). Most open source packages are packaged with GNU tar and in some cases these cannot be untar'ed using Sun tar due to some differences in how symlinks are treated I believe. The opposite is never true, i.e. GNU tar can always untar a file that was created with Sun tar.

In your organisation: Make sure GNU tar is part of your default package for new Solaris hosts !

share|improve this answer
On Solaris 11, even the native tar has compression support now, you don't need to force gtar. –  alanc Aug 16 '12 at 4:27
@alanc. Thank you for this. Wasn't aware of that. I guess you learn new stuff every day. I'll test a Linux tar file known to cause problems. I'll do the test on both Solaris 10 and Solaris 11 and update my posting accordingly. –  nolan6000 Aug 17 '12 at 8:23
add comment

In Solaris 10, use gzip -dc target.tar.gz | tar xf - to extract, after extracting you should be able to see the directory.

share|improve this answer
add comment

You missed the -c switch:

gunzip -c file.tar.gz | tar -tv
share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.