how to pack and unpack files on the server – ZIP TAR TAR.GZ
The following guide describes how to package and unpack files and directories on a Linux server
ZIP - packaging files and directories
1 | zip -r nazwa_archiwum.zip katalog1 katalog2 ... plik1 plik2 ... |
After the command and the "zip -r" parameter we specify the archive name, followed by a space after the names of directories and files that will be packed, for example,:
1 | zip -r dokumenty.zip dokumenty cv.jpg |
ZIP - unpacking files and directories
1 | unzip nazwa_archiwum.zip |
After the unzip command, we give the name of the archive in which the packed files are located, for example,:
1 | unzip dokumenty.zip |
TAR - packaging files and directories
1 | tar -cvf nazwa_archiwum.tar katalog1 katalog2 ... plik1 plik2... |
After the command with the "tar -cvf" parameters, we specify the archive name, followed by a space after the names of directories and files that will be packed, for example,:
1 | tar -cvf dokumenty.tar dokumenty cv.jpg |
TAR - unpacking files and directories
1 | tar -xvf nazwa_archiwum.tar |
After the command with the "tar -xvf" parameters, we specify the archive name. If we want to specify the place to which the files are to be extracted, we give the "-C" parameter and the target path after the archive name, for example,:
1 | tar -xvf dokumenty.tar -C /home/rafal/dokumenty |
TAR.GZ - packing files and directories with compression
To package files with compression you just need, that the tar command from the examples above will add the "z" parameter. Our command will then look like this:
1 | tar -zcvf nazwa_archiwum.tar.gz katalog1 katalog2 ... plik1 plik2... |
1 | tar -zcvf dokumenty.tar.gz dokumenty cv.jpg |
TAR.GZ - unpacking compressing files and directories
The command has the following form:
1 | tar -zxvf nazwa_archiwum.tar.gz |
If we want to add a path to the command to which the files are to be unpacked, just add the -C parameter and the target path, for example,:
1 | tar -zxvf nazwa_archiwum.tar.gz -C /home/rafal/dokumenty |