[Linux] common command tar command

[Independent command, can only use one of them, in conjunction with other command] five independent command, should be used where a compression decompression can be used in conjunction with other commands, but can only use one of them.

  • -c: the compressed file establish
  • -x: unzip
  • -t: view the content
  • -r: append to the archive file
  • -u: update the original compressed file package

 

[Optional Parameters The following parameters are required when optional file compression or decompression.

  • -z: gzip properties have
  • -j: There bz2 property
  • -Z: There compress attribute
  • -v: displays all process
  • -O: unlock the file to the standard output

 

MUST Parameters The following parameters are necessary -f

  • -f: Use file name, remember, this parameter is the last parameter, behind only access the file name.

 

[Example]

# Tar -cf all.tar * .jpg
This Order is all .jpg files labeled as a package called all.tar. -c is to generate new packages, -f specify the package file name.

# Tar -rf all.tar * .gif
This command is all. .Gif files added all.tar package to go inside. -r is meant to increase the file.

# Tar -uf all.tar logo.gif
This command is to update the original tar package all.tar the logo.gif file, -u is the meaning of the update file.

# Tar -tf all.tar
This command is to list all the files all.tar package, -t is the meaning of the listed files

# Tar -xf all.tar
This command is solved all.tar package all the files, -x is to unlock the meaning of


【compression】

  • tar -cvf jpg.tar * .jpg to package all jpg files into a directory tar.jpg
  • After tar -czf jpg.tar.gz * .jpg packaged all jpg files into directory jpg.tar, and which was gzip compression, to generate a gzip compressed package named jpg.tar.gz
  • After tar -cjf jpg.tar.bz2 * .jpg packaged all jpg files into directory jpg.tar, and compressed with bzip2 which generates a bzip2 compressed package named jpg.tar.bz2
  • After tar -cZf jpg.tar.Z * .jpg packaged all jpg files into directory jpg.tar, compress and which was compressed to generate a compressed umcompress package named jpg.tar.Z
  • rar a jpg.rar * .jpg rar compressed format, you need to download rar for linux
  • zip compression zip jpg.zip * .jpg format, you need to download the zip for linux

[Extracting]

  • tar -xvf file.tar extract the tar package
  • tar -xzvf file.tar.gz 解压 tar.gz
  • tar -xjvf file.tar.bz2 解压 tar.bz2
  • tar -xZvf file.tar.Z 解压 tar.Z
  • unrar e file.rar decompression rar
  • Extract the zip unzip file.zip

【to sum up】

  1. Unzip with tar -xvf * .tar
  2. * .Gz decompression using gzip -d or gunzip
  3. * .Tgz * .tar.gz and decompress with tar -xzf
  4. * .Bz2 with bzip2 -d or decompression with bunzip2
  5. * .Tar.bz2 decompress with tar -xjf
  6. * .Z with uncompress unpack
  7. * .Tar.Z with tar -xZf decompression
  8. * .Rar extracting with unrar e
  9. * .Zip with unzip unzip

 


 

Under linux the most common procedure is to tar the package, use the tar program to break out of the bag package we often referred to as tar, tar package file commands are usually end with the .tar. After generating tar package, other procedures can be used to compress.

1. Format:

tar [necessary parameters] [select parameters] [file] 

2. Function:

Used to compress and decompress files. tar itself does not have compression. He is calling the compression function implemented 

3. Command parameters:

Necessary parameters are as follows:

  • -A new compressed file to an existing compression
  • -B set the block size
  • -c create a new archive
  • -D difference log file
  • -r add files to already compressed files
  • Add -u to change the compressed files and existing files to the existing
  • -x to extract files from a compressed file
  • -t displays the contents of compressed files
  • -z gzip-extracting file support
  • -j bzip2 support extracting files
  • -Z support compress decompress files
  • -v display during operation
  • -l file system boundaries set
  • -k keep the original file does not cover
  • -m reserved documents not covered
  • -W confirm the correctness of the compressed file

Optional parameters are as follows:

  • -b set the number of blocks
  • Switch to the specified directory -C
  • -f specify archive
  • --help display help information
  • --version display version information

4. Common decompress / compress command

tar 
unpack: tar xvf FileName.tar
package: tar cvf filename.tar DirName
(Note:! tar package is not compressed)


.gz
extracting 1: gunzip FileName.gz
extracting 2: gzip -d FileName.gz
compression: gzip FileName

.tar.gz .tgz and
decompression: tar zxvf FileName.tar.gz
compression: the tar zcvf filename.tar.gz DirName

the .bz2
extracting 1: bzip2 -d FileName.bz2
extracting 2: bunzip2 FileName.bz2
compression: bzip2 -z FileName

.tar.bz2
decompression: tar jxvf FileName.tar.bz2
compression: the tar jcvf filename.tar.bz2 DirName

.bz
extracting 1: bzip2 -d FileName.bz
extracting 2: bunzip2 FileName.bz
Compression: Unknown

.tar.bz
decompression: tar jxvf FileName.tar.bz
compression: Unknown

.Z
decompression: uncompress FileName.Z
compression: compress FileName

.tar.Z
decompression: tar Zxvf FileName.tar.Z
compression: tar Zcvf FileName.tar.Z DirName

.zip
decompression: unzip FileName.zip
Compression: ZIP filename.zip DirName

.rar
decompression: rar x FileName.rar
compression: rar a FileName.rar DirName 

 

[Independent command, can only use one of them, in conjunction with other command] five independent command, should be used where a compression decompression can be used in conjunction with other commands, but can only use one of them.

  • -c: the compressed file establish
  • -x: unzip
  • -t: view the content
  • -r: append to the archive file
  • -u: update the original compressed file package

 

[Optional Parameters The following parameters are required when optional file compression or decompression.

  • -z: gzip properties have
  • -j: There bz2 property
  • -Z: There compress attribute
  • -v: displays all process
  • -O: unlock the file to the standard output

 

MUST Parameters The following parameters are necessary -f

  • -f: Use file name, remember, this parameter is the last parameter, behind only access the file name.

 

[Example]

# Tar -cf all.tar * .jpg
This Order is all .jpg files labeled as a package called all.tar. -c is to generate new packages, -f specify the package file name.

# Tar -rf all.tar * .gif
This command is all. .Gif files added all.tar package to go inside. -r is meant to increase the file.

# Tar -uf all.tar logo.gif
This command is to update the original tar package all.tar the logo.gif file, -u is the meaning of the update file.

# Tar -tf all.tar
This command is to list all the files all.tar package, -t is the meaning of the listed files

# Tar -xf all.tar
This command is solved all.tar package all the files, -x is to unlock the meaning of


【compression】

  • tar -cvf jpg.tar * .jpg to package all jpg files into a directory tar.jpg
  • After tar -czf jpg.tar.gz * .jpg packaged all jpg files into directory jpg.tar, and which was gzip compression, to generate a gzip compressed package named jpg.tar.gz
  • After tar -cjf jpg.tar.bz2 * .jpg packaged all jpg files into directory jpg.tar, and compressed with bzip2 which generates a bzip2 compressed package named jpg.tar.bz2
  • After tar -cZf jpg.tar.Z * .jpg packaged all jpg files into directory jpg.tar, compress and which was compressed to generate a compressed umcompress package named jpg.tar.Z
  • rar a jpg.rar * .jpg rar compressed format, you need to download rar for linux
  • zip compression zip jpg.zip * .jpg format, you need to download the zip for linux

[Extracting]

  • tar -xvf file.tar extract the tar package
  • tar -xzvf file.tar.gz 解压 tar.gz
  • tar -xjvf file.tar.bz2 解压 tar.bz2
  • tar -xZvf file.tar.Z 解压 tar.Z
  • unrar e file.rar decompression rar
  • Extract the zip unzip file.zip

【to sum up】

  1. Unzip with tar -xvf * .tar
  2. * .Gz decompression using gzip -d or gunzip
  3. * .Tgz * .tar.gz and decompress with tar -xzf
  4. * .Bz2 with bzip2 -d or decompression with bunzip2
  5. * .Tar.bz2 decompress with tar -xjf
  6. * .Z with uncompress unpack
  7. * .Tar.Z with tar -xZf decompression
  8. * .Rar extracting with unrar e
  9. * .Zip with unzip unzip

Guess you like

Origin www.cnblogs.com/zoe233/p/11957054.html