Monday 14 May 2018

How to zip and compress a directory/file in Centos7

In this article, we are using tar utility for zipping directory or files. This utility is installed by default on most of Linux distributions. The tar utility is capable to create zip file and compress the same as well.


#tar -czvf <zip-file-name.tar.gz> <directory_name>

Here are the options details which are used in the syntax:

-c: Create archive.
-z: Compress archive using gzip tool
-v: Verbose mode, display progress status while creating the archive
-f: To specify any file for the archived file.

Example 1: Run the following command to zip and compress a directory:

#tar -czvf archive-name.tar.gz directory_name

Example 2: Run the following command to zip and compress a file:

#tar -czvf archive-name.tar.gz file_name

No comments:

Post a Comment