While you might easily zip and unzip files with WinRAR on Windows, when it comes to unzipping files on Linux, you simply need to use the 'Unzip' command on your Linux or Unix system. However, it's worth noting that the 'Unzip' command isn't installed by default on Linux operating systems.
Unzipping ZIP Files on Linux
Installing the Unzip Command
First, open the Terminal application. Then run one of the following commands, depending on the Linux or Unix version you're using, to install the Unzip tool:
- For Debian / Ubuntu Linux users:
Use the following syntax with the apt-get command:
sudo apt-get install unzip
- For CentOS / RHEL / Fedora users:
Use the following syntax with the yum command:
sudo yum install unzip
How to Use the Unzip Command on Linux or Unix Systems
Utilize the following commands:
unzip zipfilename
unzip zipfilename fileToExtract
unzip [options] zipfilename
- Extract the ZIP file named foo.zip
To use Unzip to extract all contents within the Zip file into the current directory and subdirectories, and to create any necessary subdirectories, use the command:
unzip database
Alternatively:
unzip database.zip
For example, use unzip to extract a zip file on Linux named foo.zip:
unzip foo
To extract all C source files '*.c','*.h' and Makefile into the directory -/projects/editor, use the command:
unzip source.zip '*.[ch]' Makefile -d -/projects/editor
- Extract all files except bar.txt from demo.zip
Use the command:
unzip demo.zip -x bar.txt
- Extract all files into the specified directory
To extract all files into /tmp/data instead of the current default directory, use the command:
unzip demo.zip -d /tmp/data
unzip demo.zip -d /tmp/data pic1.jpg
The -o option will overwrite files without prompting the user.
Use the -n option to never overwrite existing files:
unzip -n file.zip
unzip -n file.zip data.jpg
- List the files stored within the ZIP file on the screen
Utilize the following commands:
Output result:
Hopefully, after reading Mytour's guide on unzipping ZIP files on Linux above, readers will learn additional techniques for file extraction. Additionally, readers can refer to other articles on Mytour to learn how to extract TAR files on Linux and other instructional articles on this operating system. Wishing you all success!