How to Create and Extract Zip Files to Specific Directory in Linux

In one of our several articles about the tar command, we showed you how to extract tar files to a specific or different directory in Linux. This short guide explains you how to extract/unzip .zip archive files to specific or different directory in Linux.

Zip is a simple, cross-platform file packaging and compression utility for Unix-like systems including Linux and Windows OS; plus many other operating systems. The “zip” format is a common archiving file format used on Windows PC’s and most importantly, it enables you to specify the compression level between 1 and 9 as an option.

Read Also: 5 Best Command Line Archive Tools for Linux

Create Zip Archive File in Linux

To create a .zip (packaged and compressed) file from the command line, you can run a similar command as the one below, The -r flag enables recursive reading of files directory structure.

$ zip -r tecmint_files 
Create Zip File in Linux

Create Zip File in Linux

To unzip the archive file you have just created above, you can run the unzip command as follows.

$ unzip

The above command will extract the files into the current working directory. What if you want to send the unziped files into a specific or different directory – you can learn this in next section.

Extract Zip File to Specific or Different Directory

To extract/unzip .zip archive files to specific or different directory from the command line, include the -d unzip command flag as shown below. We will use the same example above to demonstrate this.

This will extract the .zip file content into the /tmp directory:

$ mkdir -p /tmp/unziped
$ unzip -d /tmp/unziped
$ ls -l /tmp/unziped/
Extract Zip Files to Specific Directory

Extract Zip Files to Specific Directory

For more usage information, read zip and unzip command man pages.

$ man zip
$ man unzip 

You may also like to read following related articles.

  1. How to Archive/Compress Files & Directories in Linux
  2. How to Open, Extract and Create RAR Files in Linux
  3. Peazip – A Portable File Manager and Archive Tool for Linux
  4. Dtrx – An Intelligent Archive Extraction (tar, zip, cpio, rpm, deb, rar) Tool for Linux

In this short article, we have explained how to extract/unzip .zip archive files to specific or different directory in Linux. You can add your thoughts to this article via the feedback form below.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

Aaron Kili

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

4 Responses

  1. Kamath says:

    Thank you

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.