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
-dextract files into /path/to/archive
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
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.
tar to preserve extended attributes (both for compression and extraction).