Just like with the operating system running on your home computer, your server can create archives (”zip” files, compress files, to put it differently).
While creating archives through SSH isn’t as straight forward as with your own computer, it is possible.
We’ll be going over how to create three types of archives today: tar (.tar), gzipped tar (.tar.gz) and zips (.zip).
Tar
A tar archive is an archive that compresses all files included as a single file.
Code:
tar -cf archive.tar list of files separated by spaces
Gzipped Tar
A gzipped tar is a tar archive that has also been run through gzip to compress it further. This results in a smaller filesize.
Code:
tar -cfz archive.tar.gz list of files separated by spaces
Zip
A zip archive is the most popular (and widely support) archive type. With a zip archive, each file included in compressed separately. In theory, this would provide better compression due to the varying types of files that may be included. In practice, this zip archives are usually larger than their tar equivalents.
Code:
zip archive.zip list of files separated by spaces