Extract archive

Written by on .

Using unzip

Use the following command to extract a zip-file into a directory of the same name (without zip-extension):

unzip /path/to/archive.zip -d /path/to/archive

Using tar

Use the following command to extract a tar-file into a directory of the same name (without tar-extension):

cat /path/to/archive.tar | tar -x --one-top-level=/path/to/archive

And for compressed archives:

cat /path/to/archive.tar.gz | gzip -d | tar -x --one-top-level=/path/to/archive

Attributes

Basic permissions and file time statistics are preserved. But other attributes that are not stored within the file, are not preserved unless an option for this is explicitly added. Attributes that are not preserved include:

Add --xattr to tar to preserve extended attributes (both for compression and extraction).