How does Linux use the command to compress and extract to the specified directory?

Time:2019-11-30

Describes how to use the command to compress and extract a file or directory to a specified directory.

1. Command format: tar – zxvf [compressed package filename. Tar. GZ] – C [path]/

Note: extract. Tar.gz format to the specified directory

For example: tar – zxvf japan.tar.gz – C / tmp/

2. Command format: tar – jxvf [compressed package filename. Tar. Bz2] – C [path]/

Note: extract. Tar.bz2 format to the specified directory

For example: tar – zxvf japan.tar.bz2 – C / tmp/

3. Compress. Tar.gz format to the specified directory

Command format:Tar – zcvf [directory] / [compressed package filename. Tar. GZ] [source file]

For example: tar – zcvf / TMP / test.tar.gz Japan/

Note: compress multiple files at one time and directly open them in empty space after the source file

4. Compress. Tar.bz2 format to the specified directory

Command format:Tar – jcvf [directory] / [compressed package filename. Tar. GZ] [source file]

For example: tar-jcvf / TMP / test.tar.bz2 Japan/

Note: compress multiple files at one time and directly open them in empty space after the source file

matters needing attention:

Every option and command must be typed directly. Linux is strictly case sensitive. Pay attention to case when entering.

Relevant recommendations:

How to compress the disk space of Linux VMware virtual machine?

How to use the Linux bash command in the preview version of win10’s first anniversary update?

How to enable native support for Linux bash command line in 14316, the first anniversary update preview of win10?