How To Create Zip Files On Linux
You've accumulated hundreds of pictures of your pet dog Rover and now you wish to share the photos with your mates.
The only problem is that it's a pain in the butt to attach all of those files into an e-mail. Zip file to the rescue!
Zip archives are a convenient way to package and distribute multiple files and folders. Below we outline various methods you can use to create a packaged zip file!
Using the GUI to create zip fileThese days most modern linux distributions come with archiving features built-in to their file explorers.
Create zip archive with UbuntuThe steps below are specific to the default Ubuntu installation however other linux variations are same or very similar.
- Open Files and navigate to the directory where files are located
- Highlight all the files and directories you wish to package into a zip file
- Right click the highlighted items. Select "Compress..." from the menu
- The "Create Arcive" dialog will appear. Ensure ".zip" radio box is selected.
- Give the archive a name and click "Create".
How to zip files in Linux Terminal
By default, Linux OS comes with zip file support. However, if the commands do not work, then use the following to install it:
sudo apt install zip
When you are done, run the following command in terminal, to create zip file with file1 & file2 added to an archive called backup.zip:
zip backup.zip file1 file2
To packaging everything into the zip file, use the "*" wildcard:
zip backup.zip *
The zip command will output all the files added into the archive. E.g.:
To create password protected zip use the following command:
zip -p filename.zip files_to_add