If you are using a Virtual Machine and a Linux distribution as your web development environment, you have hopefully become familiar with the command line terminal by now.
It may be possible to remember a lot of basic commands, but when it comes to creation of folders and files it is best to always have a reference handy to avoid mistakes. While and FTP tool such as Filezilla is great to transfer files, it does not allow you to zip or unzip content before or after transfer. When working with large file sizes, or thousands of files in deep folder structures, compressing the content to a single archive makes for much faster transfer time and speeds.
Knowing the correct sequence of command, target, and destination along with any other flags such as compression is important to get right.
Let's start with a single file in a zipdemo folder
It contains a single text file, content.txt. This will be the file we compress and zip to a destination container.
Here you can see the command, the zip archive filename to be used, and subsequent files to include. zip squash.zip file1 file2 file3
You can list individual files one at a time to be zipped or you can use a more convenient method to zip an entire folder...
Compressing an entire folder to a zip file:
The zipdemo folder contains a single text file, content.txt. This will be the file we compress and zip to a destination archive.
the -r9 syntax translates to (-r=recursive -9=max compression) including all subfolders and files and performing the maximum compression possible.
Should you wish to include all subfolders and files but omit the parent folder...
Zipping done, lets cover Unzipping
From your folder where you transferred your zip file you will now use the unzip command From the screenshot below follow through the process of zipping the content, the zipdemo folder is removed, and the zip archive is extracted to the original location. Additionally you can specify a destination folder with the -d flag and this is illustrated with the zipdemo2 folder.
In the case of zipdemo2, the zip could be done omitting the parent folder to create a zipdemo2 set up similarly to zipdemo.
And that is about all there is to know about zip, and unzip.
Don't log in using your root account - etcetera. Thanks for reading!