tar --version
Compress
cd /etc/nginx
tar -czvf chorke-nginx_academia-production-20240628-T2023-ZP0800.tar.gz sites-enabled
tar --exclude=default -czvf chorke-nginx_academia-production-20240628-T2023-ZP0800.tar.gz sites-enabled
Decompress
tar -tzvf chorke-nginx_academia-production-20240628-T2023-ZP0800.tar.gz
tar -xzvf chorke-nginx_academia-production-20240628-T2023-ZP0800.tar.gz
tar -xzvf chorke-nginx_academia-production-20240628-T2023-ZP0800.tar.gz -C chorke-nginx-academia-production
Explanation
-c: Create a new archive
-x: Extract the archive
-z: Compress the archive with gzip
-v: Verbosely list files processed
-t: List the contents of the archive
-f: Specifies the name of the archive
Cheatsheet
Type |
Short |
Compress |
Decompress |
Algorithm |
βͺ
|
tar.gz |
-z |
time tar -czvf nginx_20240630-T1519-ZP0800.tar.gz nginx |
time tar -xzvf nginx_20240630-T1519-ZP0800.tar.gz |
DEFLATE=LZ77+Huffman |
π’
|
tar.xz |
-J |
time tar -cJvf nginx_20240630-T1519-ZP0800.tar.xz nginx |
time tar -xJvf nginx_20240630-T1519-ZP0800.tar.xz |
LZMA2 |
π
|
tar.bz2 |
-j |
time tar -cjvf nginx_20240630-T1519-ZP0800.tar.bz2 nginx |
time tar -xjvf nginx_20240630-T1519-ZP0800.tar.bz2 |
BZIP2 |
π‘
|
DateTime Format
echo "$(date +'%Y%m%d-T%H%M')-Z$(date +'%z'|tr '+-' 'PM')"
:'
20240628-T2023-ZP0800
ββ 20240628
β ββ 2024 Β« %Y
β ββ 06 Β« m%
β ββ 28 Β« %d
ββ -T2023
β ββ - Β« -
β ββ T Β« Time
β ββ 20 Β« %H
β ββ 23 Β« %M
ββ -ZP0800
ββ - Β« -
ββ Z Β« Zone
ββ P Β« {P: Plus (+), M:Minus (-)}
ββ 0800 Β« Time Offset
'
References