How to ZIP and UNZIP files in Linux?
- September 10, 2020 at 10:39 AM #3861Santhosh Kumar DKeymaster@santhosh
ZIP is the most commonly used archive file format that supports lossless data compression. A
.zipfile is a data container that contains one or more compressed files or directories. Let’s learn how to ZIP (compress) and UNZIP (decompress) files in Linux using the
How to install ZIP UNZIP in Linux?
To ZIP and UNZIP files in Linux, we need to install ZIP UNZIP first.
On Debian and Ubuntu, you can use the following command.
sudo apt-get install zip unzip
On CentOS and Fedora, you can use the following command.
sudo yum install zip unzip
How to ZIP files and directories in Linux?
To ZIP one or more files, you need to use the
zipcommand followed by name of the archive that you want to create followed by names of files that you want to add to the archive, all separated by a space as shown below.
zip archivename.zip filename1 filename2 filename3
To ZIP one or more directories, you need to use the
zipcommand with the
-roption followed by name of the archive that you want to create followed by names of files that you want to add to the archive, all separated by a space.
zip -r archivename.zip directoryname1 directoryname2 directoryname3
-roption traverses the whole directory structure recursively.
You can also add multiple files and directories to the same archive as shown below.
zip -r archivename.zip filename1 filename2 directoryname1 directoryname2
How to UNZIP files in Linux?
To UNZIP files, you need to use the
unzipcommand followed by the name of the archive that you want to UNZIP, separated by a space.
If you want to UNZIP just a single file from an archive, you can use the
unzipcommand followed by the archive name and the file name, all separated by a space.
unzip archivename.zip filename1
If you want to UNZIP files to a specific directory, then you use the
unzipcommand as shown below.
unzip archivename.zip -d ./directoryname/
Learn more Linux commands.
- How to add a percentage in Excel?
- How to convert currencies in Google Sheets?
- How to voice type on Google Docs?
- What is Django framework?
- How to turn Google Assistant off?
- How to check the Python version?
- How to create a virtual environment in Python?
- How to change the directory in the Command Prompt?
- How to add a shortcode in WordPress PHP template file?
- Useful websites to research stocks
- How to check Linux uptime?
- How to check Linux last reboot time?
- How to ZIP and UNZIP files in Linux?
- How to change the file owner and group in Linux?
- Protect your email address with Firefox Relay