Easily Unzip Files in Linux

Posted
Comments 0

Easily Unzip Files in Linux

In this guide, you’ll learn to unzip files in almost any Linux distribution, and it’s a lot easier than you think. Most Linux distributions don’t have an app for unzipping .zip files, so we need to install one first. Let’s get started.

Contents

I can highly recommend these books on Linux Administration if you want to go further.

Install unzip on Ubuntu/Debian

Open your Terminal application, then enter the following code:

sudo apt install unzip

Install unzip on Fedora/CentOS

Open your Terminal application and enter the following code:

sudo yum install unzip

How to unzip a file

To unzip a file to the current directory (the same directory the zip file is in) use the following command in Terminal:

unzip myzipfile.zip

Unzip Options (switches)

There are many options/switches you can use with unzip. Here are a few of the most useful.

-d Switch

The -d switch gives you the option of extracting the zip archive to a different folder than the current one.

unzip myzipfile.zip -d /path/to/directory

If you’re unzipping to a directory that you don’t have permissions for, use the sudo command.

sudo unzip myzipfile.zip -d /var/www

-P Switch

If the zip archive is password protected, use the -P switch.

unzip -P MyPassword myzipfile.zip

-o Switch

If you need to overwrite existing files and do not wish to be prompted, use the -o switch.

unzip -o myzipfile.zip

-n Switch

If you’ve already unzipped a file and made some changes, and for some reason need to unzip the file again (maybe you deleted some files), you can use the -n switch which will skip any existing files.

unzip -n myzipfile.zip

Conclusion

If you want to see more switches, arguments and options for unzip, see the Linux unzip man page.

Newsletter Signup







Privacy Policy

See Also

Further Reading

Author
Categories Linux, System Tools

Comments

There are currently no comments on this article.

Comment

Enter your comment below. Fields marked * are required. You must preview your comment before submitting it.





PLEASE NOTE: You must preview a comment before submitting

Comments use Textile formatting

Update cookies preferences