Create archive
Written by masteryeti on .Using zip
Use the following command to create a zip-file from a given directory (/path/to/directory):
cd /path/to/ && zip -r -y - directory >archive.zip
-r
recurse into directories-y
don't follow symlinks, store literal symbolic links
Using tar
Use the following command to create a tar-file from a given directory (/path/to/directory):
cd /path/to/ && tar -c directory >archive.tar.gz
-c
create archive
Tar is uncompressed by default, pipe to gzip to create a tar.gz-file (gzipped):
cd /path/to/ && tar -c directory | gzip -c >archive.tar.gz
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).