{"id":2974,"date":"2020-12-29T18:38:24","date_gmt":"2020-12-29T18:38:24","guid":{"rendered":"https:\/\/linuxways.net\/?p=2974"},"modified":"2020-12-29T18:38:27","modified_gmt":"2020-12-29T18:38:27","slug":"how-to-unzip-files-in-linux","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/centos\/how-to-unzip-files-in-linux\/","title":{"rendered":"How to Unzip Files in Linux\u00a0"},"content":{"rendered":"<p>The .zip extension is used for the compressed file format. This format allows you to compress all files of a directory without any data loss. Users can compress more than one directory or file at a time using Zip file format. However, when you want to extract the zip files in Linux distribution, you need to use a command-line utility that is known as \u2018unzip command\u2019. You can easily extract all types of zip files just in a few minutes using this command-line tool.<\/p>\n<p>This article will show you how you can unzip files through the terminal in a Linux environment. We have implemented the unzip command on the CentOS 8 system. These commands are the same for all Linux distributions, therefore, you can implement all these commands on Ubuntu, Debian, LinuxMint and fedora, etc.<\/p>\n<h2><strong>Use of unzip command in File Extraction<\/strong><\/h2>\n<p>The unzip command is not installed on CentOS 8. But, it is preinstalled on most of the Linux distributions. Open the terminal window from the left sidebar of your desktop in CentOS 8 and install this utility by using the following command:<\/p>\n<pre># yum install unzip<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"735\" height=\"496\" class=\"wp-image-2975\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-443.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-443.png 735w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-443-300x202.png 300w\" sizes=\"auto, (max-width: 735px) 100vw, 735px\" \/><\/p>\n<h2><strong>File Extraction using unzip command<\/strong><\/h2>\n<p>You can easily extract a zip file by using the unzip command. Using the below-given command, you can unzip a file into a current folder or directory:<\/p>\n<pre># unzip file-name<\/pre>\n<p>For example, if you want to extract a zip file \u2018myfile.zip\u2019 into the current directory \u2018Downloads\u2019 then, navigate into the \u2018Downloads\u2019 folder and list all files. Now, use the following command to unzip a file:<\/p>\n<pre># unzip myfile.zip<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"736\" height=\"500\" class=\"wp-image-2976\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-444.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-444.png 736w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-444-300x204.png 300w\" sizes=\"auto, (max-width: 736px) 100vw, 736px\" \/><\/p>\n<h2><strong>Extract file into another directory<\/strong><\/h2>\n<p>If you want to extract a zip file into another directory then, Use the -d option with the unzip command. To extract a file into a different directory, type the below-mentioned command on the terminal:<\/p>\n<pre>$ unzip file-name.zip -d \/directory-path<\/pre>\n<p>For example, you want to extract a zip file in the Documents instead of extracting it into the current Downloads. So, in this case, the following command will be used:<\/p>\n<pre># unzip myfile.zip -d \/home\/Documents\/<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"731\" height=\"492\" class=\"wp-image-2977\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-445.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-445.png 731w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-445-300x202.png 300w\" sizes=\"auto, (max-width: 731px) 100vw, 731px\" \/><\/p>\n<h2><strong>Unzip files with suppressing output<\/strong><\/h2>\n<p>During the extraction of a file, it first prints the file names and also shows a summary of task completion. If you don\u2019t want to print all file names then, use the option \u2018-q\u2019 with the unzip command as follows:<\/p>\n<pre># unzip -q myfile.zip<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"796\" height=\"75\" class=\"wp-image-2978\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-446.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-446.png 796w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-446-300x28.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-446-768x72.png 768w\" sizes=\"auto, (max-width: 796px) 100vw, 796px\" \/><\/p>\n<p>The \u2018Myfile.zip\u2019 is the name of a zip file. You can replace your own file name.<\/p>\n<h2><strong>Exclude file while extracting a ZIP file<\/strong><\/h2>\n<p>Using the \u2018-x\u2019 option with the unzip command, you can also exclude files and directories from extraction. Use the following command to exclude a file while extracting a file.<\/p>\n<pre># unzip file-name.zip -x exclude-name1 exclude-name 2<\/pre>\n<p>For example, we want to exclude the \u2018app\u2019 folder from the file extraction. So, the above command will change into the following form:<\/p>\n<pre># unzip myfile.zip -x \"*app*\"<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"734\" height=\"504\" class=\"wp-image-2979\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-447.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-447.png 734w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-447-300x206.png 300w\" sizes=\"auto, (max-width: 734px) 100vw, 734px\" \/><\/p>\n<h2><strong>Overwrite the existing extracted files<\/strong><\/h2>\n<p>If you have completed the extraction of a file and again type the unzip command then, it will ask you to overwrite or rename an existing file. If you want to ignore this prompt then, type the following unzip command with option -o:<\/p>\n<pre># unzip -o myfile.zip<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"736\" height=\"496\" class=\"wp-image-2980\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-448.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-448.png 736w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-448-300x202.png 300w\" sizes=\"auto, (max-width: 736px) 100vw, 736px\" \/><\/p>\n<p>Use the above-command carefully, due to any small mistake you can lose all your original data.<\/p>\n<p>If you don&#8217;t want to overwrite these existing files then using the option \u2018-n\u2019, you can forcefully skip all these files which have been extracted or exist.<\/p>\n<pre># unzip -n myfile.zip<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"733\" height=\"58\" class=\"wp-image-2981\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-449.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-449.png 733w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-449-300x24.png 300w\" sizes=\"auto, (max-width: 733px) 100vw, 733px\" \/><\/p>\n<h2><strong>Unzip multiple files<\/strong><\/h2>\n<p>You can also extract multiple files using the unzip command as follows:<\/p>\n<pre># unzip '*.zip'<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"737\" height=\"400\" class=\"wp-image-2982\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-450.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-450.png 737w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-450-300x163.png 300w\" sizes=\"auto, (max-width: 737px) 100vw, 737px\" \/><\/p>\n<p>At the end of the file extraction, you can see how many archives are extracted.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"744\" height=\"414\" class=\"wp-image-2983\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-451.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-451.png 744w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-451-300x167.png 300w\" sizes=\"auto, (max-width: 744px) 100vw, 744px\" \/><\/p>\n<h2><strong>List zip file contents<\/strong><\/h2>\n<p>By using the following command, you can list the contents of a zip file:<\/p>\n<pre># unzip -l myfile.zip<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"487\" class=\"wp-image-2984\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-452.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-452.png 800w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-452-300x183.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-452-768x468.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/p>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>We have elaborated on how to use the unzip command on the CentOS 8 Linux system. We have explored various uses of the unzip command through which you can list ZIP archive content and extract files. You can utilize the unzip command according to your needs.<\/p>","protected":false},"excerpt":{"rendered":"<p>The .zip extension is used for the compressed file format. This format allows you to compress all files of a directory without any data loss. Users can compress&hellip;<\/p>","protected":false},"author":2,"featured_media":2986,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[35,125],"class_list":["post-2974","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-centos","tag-linux","tag-unzip-files"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/2974","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=2974"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/2974\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/2986"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=2974"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=2974"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=2974"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}