Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Methods of compression and decompression in Linux
#1
Tar files

In order to package files, we use the following command:
Quote:
Tar -cvf file.tar / dir / a / compress /

-c : tells tar to create a file.
-v : tells tar to show what is packaged.
-f : tells tar that the next argument is the name of the .tar file.

In order to untar the .tar files, we use the following command:
Quote:
Tar -xvf file.tar

-x : tells tar to uncompress the .tar file.
-v : tells tar to show what is unpacking.
-f : tells tar that the next argument is the name of the file to be unpacked.

If you want to see the contents of a .tar file, the following command is used:
Quote:
Tar -tf file.tar

-t : List the contents of the .tar file.
-f : tells tar that the next argument is the name of the file to be viewed.

Gz files

To compress files in .gz format, the following command is used:
Quote:
Gzip -9 file

-9 : tells gz to use the largest compression factor possible.

To decompress .gz files, the following command will be used:
Quote:
Gzip -d file.gz

-d : indicates decompression

Bz2 files

To compress files in bz2 format, the following command is used:
Quote:
Bzip file

To decompress .bz2 files, use the following command:
Quote:
Bzip2 -d file.bz2

-d: indicates decompression.

Note: Both the compressor gzip and bzip2, compress only files, not directories, to compress directories (folders), must be used in combination with tar .
Tar.gz files

To compress files in tar.gz format, the following command is used:
Quote:
Tar -czfv file.tar.gz files

-c : tells tar to create a file.
-z : Indicates that you use the gzip compressor
-f : tells tar that the next argument is the name of the .tar file.
-v : tells tar to show what's packaged

To decompress files with tar.gz extension, use the following command:
Quote:
Tar -xzvf file.tar.gz

-x : tells tar to extract the contents of the tar.gz file
-z : tells tar to be compressed with gzip
-v : showing the contents of the file
-f : tells tar that the next argument is the file to decompress.

In order to see the contents of a compressed file in tar.gz, the following command is used:
Quote:
Tar -tzf file.tar.gz

Tar.bz2 files

To compress in tar.bz2, use the pipeline (|) parameter, which consists of "filtering" the output of a command to the input of another, as in this example: tar packages the different files or directories and its Output it passes it to the command bzip2 so that it compresses it and the result of this, redirects it (>) to the final file tar.bz2
Quote:
Tar -c files | Bzip2> file.tar.bz2

To decompress tar.bz2 files, the following command is used:
Quote:
Bzip2 -dc file.tar.bz2 | Tar -xv

And to see the contents of a tar.bz2 file, use the following command:
Quote:
Bzip2 -dc file.tar.bz2 | Tar -t

Zip files

In order to compress in zip format, the following command will be used:
Quote:
Zip file.zip files to compress

In order to unzip the zip files, the following command is used:
Quote:
Unzip archive.zip

To see the contents of a zip file, put the following command:
Quote:
Unzip -v zip.zip

Rar files

To compress in rar format, the following command will be used:
Quote:
Rar -a file.rar files

To decompress files in rar format, the following command is used:
Quote:
Unrar -x file.rar

To view the contents of a rar file, use the following command:
Quote:
Unrar -v file.rar
Unrar -l file.rar
Reply
Thanks given by:



Forum Jump:


Users browsing this thread: 1 Guest(s)