1.

File and Directory Compression Commands

Answer»

The files can be compressed and then extracted to save the storage. We see this happening many times in our daily lives that we have to compress some file to send it or we have to extract a downloaded file. There are several commands for file compression in Linux given below:

COMMANDMEANINGEXAMPLE & SYNTAX
gzip fileNameThis command is used to compress a file with gzip compression.

Example: The command to zip file1 using gzip compression is shown on the right.


Syntax: $ gzip file1


gunzip fileName.gzThis command is used to unzip a file that has gzip compression.

Example: The command to unzip fileDemo.gz file with gz compression is shown on the right.


Syntax: $ gunzip fileDemo.gz


tar cf myDir.tar myDirThis command is used to create an uncompressed tar archive.

Example: The command to create an uncompressed tar archive for the directory demoDir is shown on the right.


Syntax: $ tar cf demoDir.tar demoDir


tar cfz myDir.tar myDirThis command is used to create a tar archive with gzip compression.

Example: The command to create gzip tar archive for the directory demoDir is shown on the right.


Syntax: $ tar cfz demoDir.tar demoDir


tar xf fileThis command is used to extract the contents of any type of tar archive. 

Example: The command to extract the content of demoFile tar archive is shown on the right.


Syntax: $ tar xf demoFile





Discussion

No Comment Found