How To Extract A Zip File In Linux Using Terminal?

How To Extract A Zip File In Linux Using Terminal?

 

This post was last updated on August 1st, 2020 at 12:26 pm

Zip is an archive file format that supports lossless data compression. It is available for various platforms. Windows and macOS and many other OS are providing built-in zip support. These files generally use .zip or .ZIP file extension. A zip tool allows you to specify the compression level from 1 to 9.

I already discussed creating a zip archive in an article. Today in this article, we will discuss extracting or unzipping a zip file in Linux.

How to Install unzip?

Unzip command is used to list, test, and extract the .zip files in Linux. It also comes preinstalled in many Linux distributions but if it is not in your system then use one of the below commands –

Debian Based Ubuntu, Linux Mint, etc:

If you are using a Debian based distribution such as Ubuntu, Linux Mint, etc. then use –

sudo apt-get install unzip

RPM-based CentOS, RedHat Linux, etc:

If you are using a system that uses yum package manager then use –

sudo yum install unzip

For Fedora:

To install it in fedora use –

sudo dnf install unzip

How to list the files and directories inside a zip file?

To display the list of files and directories inside a zip file named sample.zip you could use the following command in the terminal –

unzip -l sample.zip

 

Here you can see the listed files and directories along with some other information.

How to unzip a zip archive?

In its simplest form, this will extract the files and directories inside a directory with the same name as a zip file has. Suppose we have sample.zip in the home directory of my system. To extract files from this zip file I will use the following command in the terminal –

unzip sample.zip

How to extract a zip archive into a specific directory?

If you want to extract/unzip a zip archive into a specific directory then use the following steps –

Create a directory if not created already by using –

mkdir extracted_files

The above command will create a directory named extracted_files inside the current working directory. Now to unzip the content of zipped file inside the created directory, use the following command –

unzip sample.zip -d extracted_files

How to extract a password-protected zip file?

Suppose we have a zip file sample.zip which is password protected. If you want to extract it then use the following command and enter the password if prompted.

unzip sample.zip

This will extract all the files and directories inside a directory named sample.

Conclusion

Now if you want to explore more options that can be used with the unrar command then see its manual page. To see the manual page, use the following command in the terminal –

man unzip

If you have any thoughts related to this article, share it with us in the comments below.

Previous How To Create A Zip File In Linux?
Next How To Create A Password Protected Zip Archive In Linux?
 

About author

You might also like

Linux Topics 0 Comments

How To Install And Use Linux Containers (LXC) On Ubuntu?

LXC (Linux containers) is the operating system-level virtualization which is used for running multiple isolated Linux systems called containers on a host machine. Unlike a virtual machine that requires dedicated

How To 0 Comments

How To Create A Zip File In Linux?

This post was last updated on August 1st, 2020 at 12:29 pmZip is an archive file format that supports lossless data compression. Zipping and unzipping tools are available for various

How To 0 Comments

How To Set Password On A RAR Archive In Linux?

This post was last updated on August 1st, 2020 at 01:19 pmFiles inside a RAR archive can have important data. So you may want to protect it from the unusual

0 Comments

No Comments Yet!

You can be first to comment this post!

Leave a Reply