INFO PRESERVE PERMISIONS
!!! Zip still doesn't support unix file permissions. !!! It doesn't matter if it was created on windows or *nix.
Zip 3.0 SUPPORTS preserving files/dirs UNIX permissions and UID/GID ownership data. zip stores it by default but you need to use unzip in an special way to restore them:
unzip must be used with the -X flag.
unzip must run as root to set the files/dirs UID/GID. If you run it as a normal user then the UID will be always the one of the current user and the GID will be restored ONLY IF the current user belongs to that group.
ZIP
zip -r /tmp/archiv.zip /home/user
<===> create a zip archive of a directory including the content of subdirectories. The -r option allows you to traverse the whole directory structure recursively:zip -r archivename.zip directory_name1 directory_name2 file1 file1
<===> can also add multiple files and directories in the same archivezip myfile.zip filename.txt
<===> zabali soubor filename.txt zipemunzip {archiv.zip}
<===> Vybali archiv {archiv.zip} do stavajici slozky / vytvori podadresareunzip -l {archiv.zip}
<===> Pouze vypise seznam vsech zabalenych souboru v archivu {archiv.zip}unzip -tq {archiv.zip}
<===> Otestuje archiv {archiv.zip} zda neni chybovy, ale nic nevybali. -q znamena "tise".zipinfo {archiv.zip}
<===> Zobrazi podrobne informace o archivu {archiv.zip}
!! The default compression method of Zip is deflate. If the zip utility determines that a file cannot be compressed, it simply stores the file in the archive without compressing it using the store method.
!! In most Linux distributions, the zip utility also supports the bzip2 compression method.
zip -r -Z bzip2 archivename.zip directory_name <===> To specify a compression method, use the -Z option.
!! The zip command allows you to specify a compression level using a number prefixed with a dash from 0 to 9. The default compression level is -6. When using -0, all files will be stored without compression. -9 will force the zip command to use an optimal compression for all files.
zip -9 -r archivename.zip directory_name <===> For example, to use the compression level -9, you would type something like this
Creating a Password Protected ZIP file
zip -e archivename.zip directory_name
<===> If you have sensitive information that needs to be stored in the archive, you can encrypt it using the -e option
Creating Split Zip File
Imagine you want to store the Zip archive on a file hosting service that has a file size upload limit of 1GB, and your Zip archive is 5GBzip -s 1g -r archivename.zip directory_name
<===> You can create a new split Zip file using the -s option followed by a specified size. The multiplier can be k (kilobytes), m (megabytes), g (gigabytes), or t (terabytes).
TAR
tar --same-owner -xvf file.tar
<===> pokud chci pri vybalovani zachovat i vlastnicka prava uzivatele/skupiny
tar -xzvf {archiv.tar.gz}
<===> Vybali soubory ze gzip-TARu {archiv.tar.gz} -z znamena ze archiv je gzipovanytar -tvf {archiv.tar}>
<===> Pouze vypise seznam vsech zabalenych souboru v archivu {archiv.tar} tar -xf {archiv.tar}
<===> Vybali soubory z archivu {archiv.tar}tar -cf {archiv.tar} slozka/
<===> Vytvori archiv z adresare "slozka"tar -czf /tmp/archiv.tar.gz /home/user
<===> Vytvori gzip-archiv z adresare "user" v hometar -xvf {archiv.tar} --wildcards '*.doc'
<===> Vybali pouze soubory s koncovkou .doc z archivu {archiv.tar}tar -xvf foo.tar
<===> Extract a tar file footar -xvzf foo.tar.gz
<===> Extract and uncompress a tar.gz file footar -xvjf foo.tar.bz2
<===> Extract and uncompress a tar.bz2 file foo
tar -cvf bu.tar /home/bu
<===> Tar slouží k archivaci, k uložení určených souborů do jednoho soubor archivu. Pokud je třeba kupříkladu archivovat celý adresář uživatele bu včetně podadresářů
GZIP
gzip file.txt
<===> Zabali soubor {file.txt} gzipem vysledek file.txt.gzgunzip file.txt.gz
<===> Vybali soubor file.txtgzip -d file.txt.gz
<===> Vybali soubor file.txtgzip and gunzip
<===> Reduces the size of the named files using Lempel-Ziv coding
BZIP
bzip2 and bunzip2
<===> Compresses files using the Burrows-Wheeler block sorting text compression algorithmxz and unxz
<===> Compression utility based on the LZMA algorithm ned by Igor Pavlov as part of 7-Zipzip and unzip
<===> Compression and file packaging utility compatible with PKZIP (Phil Katz's ZIP)cpio and tar
<===> Programs to manage archives of files
RAR
apt-get install unrar
<===> instalace unraruunrar x filename.rar
<===> rozbalení RARu (nebo sudo unrar x *)unrar l filename.rar
<===> If you want to see what's inside the RAR file before extracting the files, you can use this command to view the files and structureunrar t filename.rar
<===> to test the integrity of a file.This checks the structure of the RAR archive and displays the results
XZ
sudo apt install xz-utils
<===> Install xz-utils package using the relevant package manager for your Linux and matched package name.
unxz file.xz
<===> rozbali file.xz
The .xz file is automatically deleted after decompression!!