Knowledgebase

How to Create and Extract Zip Files to Specific 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.

 

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 rootadminz_files.zip rootadminz_files 

 

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

$ unzip rootadminz_files.zip 

 

The above command will extract the files into the current working directory. What if you want to send the unzipped files into a specific or different directory – you can learn this in the 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 rootadminz_files.zip -d /tmp/unziped
$ ls -l /tmp/unziped/

 

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

$ man zip
$ man unzip 
  • Create and Extract Zip Files
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to upload a file using File Manager in cPanel

Sometimes it's necessary to upload files to your cPanel account. This can be easily accomplished...

How to configure custom name servers

If you have a reseller, you can set up and use custom name servers. For example, if your domain...

How to Create WHM Accounts/Master/Alpha in Zamfoo ??

1. Login to your WHM 2. Click on Add Package 3. Create a Package for Reseller/MasterReseller...

How to add a package in WHM?

How do I add, edit and delete packages in WHM? The following article explains how to add, edit...

How to Configure PayPal in WHMCS

Part 1: Initial Setup in WHMCS    Begin by going to Setup > Payment Gateways in WHMCS....