How to Compress and Extract Files and Directories in Linux Using gzip

Gzip Compression

To compress a file:

 
gzip file1

A file by name file1.gz will be created in current directory replacing file1. You can compress multiple files in one go by just specifying their names, separated by spaces. For example:

 

gzip file1 file2 file3

To expand a gzip compressed file in current directory:

 
gunzip file1.gz

To compress a directory, you can create a tar and compress it.

 
tar -czvf name-of-archive.tar.gz /path/to/directory

To compress multiple directories in one file:

 
tar -czvf name-of-archive.tar.gz /path/directory1 /path/directory2

To extract the a “tar and compressed” directory in your current directory,

 
tar -xzvf name-of-archive.tar.gz

To extract the a “tar and compressed” directory in a particular directory,

 
tar -xzvf name-of-archive.tar.gz -C /path/to/directory
這篇文章有幫助嗎?

相關文章

How to install and use MTR on Windows and Mac OS X

Install and use MTR on Windows Download WinMTR (Windows) (Windows) Run WinMtr.exe...

How to use worldshield.ws panel

Worldshield.ws is the DDoS mitigation control panel that nexonhost.com provides for you to manage...

How to get Real Visitors IPs on your backend

How to Get Real Visitor IPs in Web Server Access Logs In order to receive the real visitor IPs...

How to use the MTR command on Linux

How to use the MTR command on Linux   MTR (Matt’s traceroute) is a...

How to Install PowerDNS and Poweradmin on CentOS 7

Step 1 - Install EPEL and Remi Repositories First of all, we need to install dependencies for...