Extract archive
Written by masteryeti 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
-d
extract files into /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
-x
extract 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:
- Filesystem file attributes such as immutable (chattr, lsattr).
- Extended attributes (xattr), including SELinux contexts and Access Control Lists (ACL) which are typically stored in xattr.
Add --xattr
to tar
to preserve extended attributes (both for compression and extraction).