Installing and using unzip Command to unzip a zip file using Terminal


Hello there! The easiest way to unzip a file using the Terminal (Command Line) is by making use of the unzip command.

You will get an error "bash: unzip: command not found" if you do not have to unzip the binary installed on your Linux/Ubuntu/macOS.


Step 1: Installing unzip command

Based on which Operating System you are on, make use of the package manager to get unzip installed. Below is an example using apt-get for Ubuntu,

# apt-get update
....
....

# apt-get install unzip
The following NEW packages will be installed:
  unzip
...
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package unzip.
(Reading database ... 4389 files and directories currently installed.)
Preparing to unpack .../unzip_6.0-26ubuntu3.1_arm64.deb ...
Unpacking unzip (6.0-26ubuntu3.1) ...
Setting up unzip (6.0-26ubuntu3.1) ...
installing unzip on Ubuntu

Note: You may need sudo privileges.



Step 2: Using unzip command to unzip files

Example 1: Unzip a file in the current location
# unzip mydata.zip 
Archive:  mydata.zip
 extracting: a.txt 
unzip a zip file using terminal

Example 2: Unzip a file in a directory
# # unzip -d ~/myDir mydata.zip
Archive:  mydata.zip
 extracting: /root/myDir/a.txt

Make use of the -d flag followed by the directory path where you want to unzip the zip file.

Unzip a zip file into a directory
-

Facing issues? Have Questions? Post them here! I am happy to answer!


Author Info:

Rakesh (He/Him) is a seasoned developer with over 10 years of experience in web and app development, and a deep knowledge of operating systems. Author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap