- Creating a Zip File
To create a zip file, use the following syntax:
zip -r output.zip input_directory/
This will create a zip file called output.zip
containing all the files and directories inside input_directory/
.
- Extracting a Zip File
To extract a zip file, use the following syntax:
unzip output.zip
This will extract all the files and directories inside output.zip
to the current directory.
- Listing the Contents of a Zip File
To list the contents of a zip file, use the following syntax:
unzip -l output.zip
This will display a list of all the files and directories inside output.zip
.
- Updating a Zip File
To update a file inside a zip file, use the following syntax:
zip -u output.zip input_file
This will update the file input_file
inside output.zip
if it has been changed more recently than the version that already existed inside the zip archive.
- Testing a Zip File
To test the integrity of a zip file, use the following syntax:
zip -t output.zip
This will test the files inside output.zip
with a cyclic redundancy check.
- Extracting a Zip File to a Specific Directory
To extract a zip file to a specific directory, use the following syntax:
unzip output.zip -d /path/to/directory/
This will extract all the files and directories inside output.zip
to the directory /path/to/directory/
.
- Creating a Zip File with a Specific Compression Method
To create a zip file with a specific compression method, use the following syntax:
zip -r -0 output.zip input_directory/
This will create a zip file called output.zip
containing all the files and directories inside input_directory/
with no compression.
- Extracting a Zip File with a Password
To extract a zip file with a password, use the following syntax:
unzip -P password output.zip
This will extract all the files and directories inside output.zip
with the password password
.
- Creating a Solid Zip Archive
To create a solid zip archive, use the following syntax:
zip -r -mson output.zip input_directory/
This will create a solid zip archive called output.zip
containing all the files and directories inside input_directory/
.
- Extracting a Zip File with a Specific Compression Method
To extract a zip file with a specific compression method, use the following syntax:
unzip -a output.zip
This will extract all the files inside output.zip
with the LZMA compression method, which usually offers the highest compression rates.
These are just some of the possible things you can do with the zip
command in the terminal. For more information, you can refer to the man pages or online documentation.
Citations:
[1] https://www.javatpoint.com/linux-zip-command
[2] https://www.cyberciti.biz/faq/how-to-zip-a-folder-in-ubuntu-linux/
[3] https://askubuntu.com/questions/86849/how-to-unzip-a-zip-file-from-the-terminal
[4] https://realpython.com/lessons/zipfile-from-command-line/
[5] https://www.dotnetperls.com/7-zip-examples