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). |
Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!