DEV Community

cloudytech147
cloudytech147

Posted on

Guide on How to Unzip Files in Linux?

it's consistently dangerous when we work with sudo advantages in a Linux machine as you approach all the setup and framework records, and if you mess up with them, your entire framework may crash. So we encourage you to run the underneath referenced orders with absolute attention to detail.

Additionally, to utilize the unfasten order, it's required to have the unfasten bundle introduced on our Linux machine. You can basically utilize the bundle administrator of any famous Linux circulation you are rushing to introduce the unfasten bundle. Notwithstanding, the vast majority of the Linux appropriations come pre-introduced with this bundle.


$ sudo apt-get -y install unzip

Linux unzip

If you are using Fedora, CentOS, etc. and you have yum package manager, you can use:


$ sudo yum install unzip

How to Unzip Files in Linux?

When we run the unzip command without any options, in the most native form, it simply extracts all the files and directories inside the current directory that you are in.


$ unzip archive.zip

unzip archive

Output Suppression

You can see that the unzip command enlists the details of the files that it is extracting from the archived file. To avoid printing the details and suppress the output, we can simply use the quiet (-q) option along with the unzip command.


$ unzip -q archive.zip

unzip -q archive

How to Extract Files to a Different Directory in Linux?

If you want to extract them to a different directory, you can use the -d option and specify the path to the destination directory. Please note that if you don’t have write access to the destination directory, you can use the sudo command to get the root privileges.


$ unzip archive.zip -d ~/Documents

unzip archive.zip -d ~/Documents

How to Extract a Password-Protected File in Linux?

If you want to unzip a file that is password-protected, you can use the -P option along with the unzip command.


$ unzip -P <password> <zipped-file>

unzip -P <password> <zipped-file>

However, typing the password as plain text in the terminal (command line) could be insecure. What you can do is simply extract the zipped file in a normal manner. When it tries to unzip the files and finds a file with a password, it will automatically prompt you to input the password.


$ unzip archive.zip

unzip archive.zip

Wrapping Up!

To conclude this detailed and comprehensive article, we discussed how to unzip files in Linux using the unzip command.

Discussion (0)