How to ZIP and UNZIP files in Linux?
Tagged: linux
- AuthorPosts
- September 10, 2020 at 10:39 AM #3861
Santhosh Kumar D
Keymaster@santhoshZIP is the most commonly used archive file format that supports lossless data compression. A
.zip
file 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 thezip
command.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
zip
command 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
zip
command with the-r
option 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
The
-r
option 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
unzip
command followed by the name of the archive that you want to UNZIP, separated by a space.unzip archivename.zip
If you want to UNZIP just a single file from an archive, you can use the
unzip
command 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
unzip
command as shown below.unzip archivename.zip -d ./directoryname/
Learn more Linux commands.
- AuthorPosts
Advertisement
RECENT TIPS
- How to send email as an alias in Gmail?
- How to stop Google from tracking your location?
- Command to check the Ubuntu version
- 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?