unzip command in Linux with Examples

unzip command in Linux means list, test and extract compressed files in a ZIP archive.

unzip command in Linux with Examples

Syntax

unzip [-Z] [-cflptTuvz[abjnoqsCDKLMUVWX$/:^]] file[.zip] [file(s) …] [-x xfile(s) …] [-d exdir]

On the man page, the describes it

  • unzip – list, test and extract compressed files in a ZIP archive
  • man unzip – More details information about unzip command.

unzip command in Linux with Examples

$ unzip devopsroles.zip

List all files from a .zip file

[vagrant@DevopsRoles ~]$ ll
 total 4
 -rw-rw-r--. 1 vagrant vagrant 638 Oct  1 06:46 Devops.zip
 [vagrant@DevopsRoles ~]$ unzip -l Devops.zip 
 Archive:  Devops.zip
   Length      Date    Time    Name
 ---------  ---------- -----   ----
         0  10-01-2019 06:45   Devops/
         0  10-01-2019 06:45   Devops/DevopsRoles/
         0  10-01-2019 06:45   Devops/huupv.csv
         0  10-01-2019 06:45   Devops/xxx
 ---------                     -------
         0                     4 files

Test a .zip file validity

[vagrant@DevopsRoles ~]$ unzip -tq Devops.zip 
 No errors detected in compressed data of Devops.zip.

How to extract unzip all files/folders into a certain directory

[vagrant@DevopsRoles ~]$ ll
 total 4
 -rw-rw-r--. 1 vagrant vagrant 638 Oct  1 06:46 Devops.zip
 [vagrant@DevopsRoles ~]$ unzip Devops.zip -d DevopsRoles
 Archive:  Devops.zip
    creating: DevopsRoles/Devops/
    creating: DevopsRoles/Devops/DevopsRoles/
  extracting: DevopsRoles/Devops/huupv.csv  
  extracting: DevopsRoles/Devops/xxx  
 [vagrant@DevopsRoles ~]$ ll
 total 4
 drwxrwxr-x. 3 vagrant vagrant  20 Oct  1 06:51 DevopsRoles
 -rw-rw-r--. 1 vagrant vagrant 638 Oct  1 06:46 Devops.zip

Conclusion

unzip command is a simple command in Linux. It is the most popular in use terminal Linux list, test and extracts compressed files in a ZIP archive. Thank you for reading the DevopsRoles page!

About HuuPV

My name is Huu. I love technology and especially Devops Skill such as Docker, vagrant, git so forth. I likes open-sources. so I created DevopsRoles.com site to share the knowledge that I have learned. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

Leave a Reply

Your email address will not be published.

Comment moderation is enabled. Your comment may take some time to appear.

This site uses Akismet to reduce spam. Learn how your comment data is processed.