If you have a .zip file on your Ubuntu system and you are wondering how to unzip the file using the Terminal (Command Line), well you can make use of the unzip binary.
First thing we need to check if unzip is installed on your Ubuntu system by just typing unzip on on the Terminal Prompt.
# unzip
bash: unzip command not found.
If you get the command not found, well you need to get it installed (this will be the case if you are using a docker image of Ubuntu).
To download and install unzip we will need to make use of the apt-get package manager.
sudo apt-get install unzip
Installation logs:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Suggested packages:
zip
The following NEW packages will be installed:
unzip
0 upgraded, 1 newly installed, 0 to remove, and 0 not upgraded.
Need to get 171 kB of archives.
After this operation, 360 kB of additional disk space will be used.
Get:1 http://ports.ubuntu.com/ubuntu-ports jammy-updates/main arm64 unzip arm64 6.0-26ubuntu3.1 [171 kB]
Fetched 171 kB in 1s (179 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package unzip.
(Reading database ... 4457 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) ...
Now we are good to unzip our zip file.
unzip my_zip_file.zip
Note this will extract the contents of the zip file in the current directory.
If you wish to unzip the contents to a specific location then you can make use of the -d parameter.
Example:unzip my_zip_file.zip -d path/to/the/destination/directory
The best way to know more about the utility is by using the unzip -hh option
root@adf079f415ef:/# unzip -hh
Extended Help for UnZip
See the UnZip Manual for more detailed help
UnZip lists and extracts files in zip archives. The default action is to
extract zipfile entries to the current directory, creating directories as
needed. With appropriate options, UnZip lists the contents of archives
instead.
Basic unzip command line:
unzip [-Z] options archive[.zip] [file ...] [-x xfile ...] [-d exdir]
Some examples:
unzip -l foo.zip - list files in short format in archive foo.zip
unzip -t foo - test the files in archive foo
unzip -Z foo - list files using more detailed zipinfo format
unzip foo - unzip the contents of foo in current dir
unzip -a foo - unzip foo and convert text files to local OS
....
Flag | Description |
---|---|
-Z | Switch to zipinfo mode. Must be the first option. |
-hh | Display extended help. |
-A | Print extended help for DLL (OS/2, Unix DLL). |
-c | Extract files to stdout/screen. Includes names. EBCDIC conversions are done if needed. |
-f | Freshen by extracting only if the file on disk is older. |
-l | List files using short form. |
-p | Extract files to pipe (stdout). Only file data is output in binary mode. |
-t | Test archive files. |
-T | Set timestamp on archive(s) to that of the newest file. |
-u | Update existing older files on disk as well as extract new files. |
-v | Use verbose list format. Can also be used to show version information. |
-z | Display only the archive comment. |
-a | Convert text files to the local OS format. Handles line ends, EOF marker, and EBCDIC character set conversions. |
-b | Treat all files as binary. |
-C | Use case-insensitive matching. |
-D | Skip restoration of timestamps for extracted directories. |
-j | Junk paths and deposit all files in the extraction directory. |
-L | Convert uppercase-only names to lowercase. |
-n | Never overwrite existing files. Skip extracting that file without prompt. |
-o | Overwrite existing files without prompting. |
-q | Perform operations quietly. The more q (as in -qq), the quieter. |
-s | Convert spaces in filenames to underscores. |
-U | Show non-local characters as ASCII text escapes. |
-V | Retain VMS file version numbers. |
-W | Modify pattern matching to allow matching at specific directory levels. |
-X | Restore UICs and ACL entries under VMS, or UIDs/GIDs under Unix, or ACLs under certain operating systems. |
-Y | Treat archived name endings of .nnn as VMS version numbers. |
-$ | Restore volume label if the extraction medium is removable. |
-/ e | Use e as the extension list. |
-^ | Allow control characters in names of extracted entries. |
-2 | Force unconditional conversion of names to ODS-compatible names (VMS). |
Facing issues? Have Questions? Post them here! I am happy to answer!
- Install Oh My Zsh on Ubuntu Docker complete steps
- Installing Home-brew on Ubuntu
- Install Golang (Go) on Ubuntu
- Install specific JRE on Ubuntu using apt
- How to stop/start/restart apache server using command [Ubuntu]
- How to install zsh shell on Ubuntu
- Quick steps to install Nginx on Ubuntu Linux
- How to know current Ubuntu Linux version via terminal command
- Add new user in Ubuntu Linux using Terminal Command
- Fix Ubuntu /bin/sh: 1: zsh: not found error
- How to install Python on Ubuntu
- [Fix] Ubuntu E: Unable to locate package sudo error
- How to stop MongoDB Server running on Ubuntu
- Install postgres Client using apt-get command
- How to kill service running on a port on Ubuntu Linux
- [fix] openssl No such file or directory error C++
- Fix - sudo: systemctl: command not found
- Access Windows share folder in Ubuntu Device in Network
- Add or remove users from sudo group - Ubuntu
- Quickly install Apache Server on Ubuntu Linux
- Fix: Ubuntu (Linux) - bash: sudo: command not found error
- Java Date Time API: LocalDateTime get(TemporalField field) examples - Java
- Java 8 JDBC: Insert Timestamp Code Example - Java
- [macOS] Fix: MySQL ERROR 2002 (HY000): Cant connect to local MySQL server through socket /tmp/mysql.sock (2) - MySQL
- Java: Convert Double to 2 Decimal Places [Examples] - Java
- MySQL : Error :1004 SQLSTATE: HY000 (ER_CANT_CREATE_FILE) Can't create file - MySQL
- Split String in Python with Multiple Delimiters - Python
- Install SonarLint on Visual Studio Code - HowTos
- Parsing Data for android-21 failed unsupported major.minor version 51.0 - Android