How to unzip file in Linux by commands and GUI with multiple options

Vijay Kumar
5 min readJun 17, 2019

--

There is no doubt, using Linux by command line interface is more simple and easy than GUI. But Most of the users are familiar and habitual with a graphical interface.

They can’t change their habits easily, Why so they can’t switch themselves for using command line interface in Linux.

Similar to other tasks, It is so easy to unzip a zip file in Linux. In this article, You will learn how to unzip a file in Linux by using commands with single unzip utility. You can also use graphical Interface to extract zip files.

I am using Ubuntu 19.04 and a compressed zip file WordPress in this article you can download this compressed file from here

Let’s talk about how to unzip zip file in Linux. Unzip utility is used to unzip files.

What is Unzip command?

unzip is utility pre-installed in Ubuntu 19.04 used to extract content from zip compressed files.

If you want to know more about unzipping utility use following command syntax in Ubuntu to check the manual page of unzip command.

$man unzip

Read all pages carefully.

How to list the content of zip file

You are going to extract files but don’t what are contents inside the zip file. You can read content from a zip file without extracting it.

You can see exist content of zip file easily by using following command.

Use unzip command followed by -l option and name of zip file with .zip extension. You can see an example in the following:

vijay@Ubuntu-19 : ~/Downloads $ls 
file_2.txt wordpress-5.2.1.zip :
vijay@Ubuntu-19 $unzip -l wordpress-5.2.1.zip
Archive: wordpress-5.2.1.zip Length Date Time Name --------- ---------- ----- ---- 0 2019-05-21 23:54 wordpress/ 3068 2018-08-17 07:21 wordpress/xmlrpc.php 369 2017-12-01 04:41 wordpress/wp-blog-header.php 7447 2019-04-09 04:29 wordpress/readme.html 31085 2019-01-16 22:21 wordpress/wp-signup.php 420 2017-12-01 04:41 wordpress/index.php 3847 2019-01-09 14:07 wordpress/wp-cron.php 2898 2019-01-08 10:00 wordpress/wp-config-sample.php 39574 2019-04-16 04:09 wordpress/wp-login.php 18962 2019-03-29 00:34 wordpress/wp-settings.php 19935 2019-01-02 02:07 wordpress/license.txt~/Downloads

You can use | more option for reading line by line contents files.

How to unzip a zip file in the same directory

You have seen content inside the zip file. Now do you like to extract it?

Yes, It is time to unzip file. Here is simple text to unzip file in Linux

$unzip filename.zip

If you bother to display a long list of logs on the screen then you can use unzip command followed by -q option. It will extract files silently without showing anything on the screen.

How to unzip a zip file in Different directory

Don’t you want to extract file in the same directory? Don’t worry! you don’t need a specific skill to do so.

For the example, You have downloaded the wordpress zip file in Download folder. But you want to extract in another location. I am going to unzip a file in /home/vijay/Documents directory.

I used following syntax:

$unzip -q wordpress-5.2.1.zip -d /home/vijay/Documents/

I didn’t want to display long list on the screen. So, I used -q option before zip file name.

How to unzip and overwrite existing files

When you think about overwrite existing files, one question stuck in your mind.

Why do you unzip file again if you have already?

It is possible everyone has difference reasons for this answer. About my story.

I had a WordPress website and it was running pretty good. But after sometime, I was getting issues on my client’s website.

I audited and checked security for a wordpress website. I found “website has been hacked and lots of code has been injected in some files?

It was not possible to check code for every file, So I downloaded WordPress core files, Theme, and plugins. Extracted and overwrite all files.

You can use following command to do same

vijay@Ubuntu-19 : ~/Downloads $unzip wordpress-5.2.1.zip 
Archive: wordpress-5.2.1.zip replace wordpress/xmlrpc.php? [y]es, [n]o, [A]ll, [N]one, [r]ename: A

When you use unzip command followed by file name and unzip files in the same folder where files exist already.

It will ask for overwriting. Press Y if you want to check and replace files one by one. Choose A option for overwriting all files.

Use -o option without prompting your confirmation to overwrite files.

How to unzip without overwriting existing files

I am working as Linux administrator and unzip a zip file in Linux operating system, Then I handover over the system to the user.

After some time same user reported some files have been deleted accidentally. I have two options:

One is extract all the files and overwrite.

If you are thinking same then remember this is a flop idea forever. Because If the user has made some changes in files, will be lost.

Second is extract all the files without overwrite existing file

Thumbs up for this idea, In this way, Existing files will remain same and deleted file will be restored from the archive.

How to unzip password protected file

Use unzip command followed by -P password for file and filename.

How to unzip multiple files in Linux

Following command can be used to unzip multiple files.

How to unzip file in Linux using GUI

Graphical user interface is very loving and popular interface in world wide. It has limitations.

Here I am going to extract files in Linux by using Graphical interface.

First step open the folder where zip file is exist.

Right click on zip file and click on extract Here. This option will extract file in same folder.

You can see the result in following image.

If you want to extract zip file in different location then

Right Click on zip file > Extract to

Browse the location where you want to extract content from zip file and click on select option

The files will be extracted in selected location.

Conclusion

In this article, you have learned how to unzip a zip file in Linux with multiple options. If you have any question related unzip a file in Linux writes a comment below.

Originally published at https://www.cyberpratibha.com on June 17, 2019.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response