Linux compressed archive management

What is compression?

    Compression is to use the time for space, CPU time exchange of disk space, download transfer process may save bandwidth.

zip/unzip

zip multi-platform support, support compressed archive. compressed file after it would otherwise generate a compressed file with the extension ".zip" is.

zip

Syntax:   ZIP [Options] / the PATH / the TO / somefile. ZIP [zip file / directory compression] 

OPTIONS:

Options Explanation
-r  Recursive processing, all the files and subdirectories in the specified directory dealt with together.
-b <Working directory> Specifies the temporary file storage directory
-d Delete the specified file from within the compressed file.
-q During instruction execution are not displayed.
-v  Display instruction execution or display version information.

 


unzip

Syntaxthe unzip / the PATH / the TO / somefile. ZIP 

gzip/gunzip/zcat

After a gzip compressed file, the file will be more of a .gz suffix. gzip command 60% to 70% compression ratio for text files. It does not support compression directory.

gzip

Syntax:  gzip [the OPTIONS] File > File .gz 

OPTIONS:

Options  Explanation
-c The compressed or decompressed file output results to standard output, without this parameter to delete the source files.
-d Decompression, equivalent to gunzip
-# 1-9, specify the compression ratio, the greater the value the greater the compression ratio
-v   Output details
-l Details are listed in the file compression

 

gunzip

Syntax:  gunzip -c File .gz> File  

zcat

View does not display text compression premise.

Syntax:  zcat File .gz> File  

bzip2/bunzip2/bzcat

-K parameters without compression, delete the source files for the directory can not be compressed.

Linux bzip2 command is .bz2 file compression program.

bzip2 new compression algorithm, compression than conventional LZ77 / LZ78 compression algorithms to well. If you do not add any parameters, bzip2 compressed file will have the .bz2 compressed the file, and delete the original file.

bzip2


Syntax:  bzip2 [the OPTIONS] FILE .... 

OPTIONS:

Options Explanation
-c The compressed or decompressed result output to the standard output file
-k Keep source file
-k  Keep source file
-# 1-9, specify the compression ratio

bunzip

Decompress .bz2 files.

Syntax:  bunzip2 File .bz2 

bzcat

View does not display the contents of a text file compression premise.

Syntax:   bzcat File .bz2 

xz/unxz/xzcat

-K parameters without compression, delete the source files for the directory can not be compressed.

xz

Syntax:  the xz [OPTION] ... FILE ... 

OPTIONS:

Options Explanation
-c The compressed or decompressed result output to the standard output file
-k Keep source file
-k  Keep source file
-# 1-9, specify the compression ratio

unxz

Decompression .xz file.

Syntax:   unxz File .xz 

xzcat

View does not display the contents of a text file compression premise.

Syntax:  zcat File .xz  

takes

Tar (Tape ARchive, tape archive acronym)

Linux tar command is used to back up files.

tar is used to create, restore utilities to back up files, it can be added, unlock the files in the backup file.

Syntax:   tar . [The OPTIONS] / path / to / somefile tar .. FILE .... 

OPTIONS:

Options   Explanation
-c Create a new archive
-C <Destination directory> or --directory = <destination directory> switch to the specified directory.
-f Specify the backup file
-r Append files to the archive does not support the compressed file to append
-x  Expand the archive
-j Archive and compressed with bzip2
-from Archive and compressed using gzip
-J Archive and compressed using xz
-T Enter the specified files to back up, / root / includefilelist
-X Specified that contains the list of excluded files, / root / excludefilelist

 

This chapter exercises

1. Compression / etc / sysconfig / all of the following files to / tmp / config.zip and named under compression from the solution to config.zip / List / ZIP / 


2. were used gzip, bzip2, xz compression / etc / fstab file to /tmp/[fatab.gz,fatab.bz2,fstab.xz], does not view the decompressed file, respectively, to extract / list / [gzip, bzip2, xz]. ( reserved source) 


3. the tar command, respectively [ gzip, bzip2, xz] archiving compression / usr / local / * next to tmp, respectively, to extract / list / tar named in a compressed format.

  

answer:

 1 1. 
 2 zip -r /tmp/config.zip /etc/sysconfig/
 3 unzip -d /list/zip/ /tmp/config.zip
 4 
 5 2. 
 6 zcat /tmp/fstab.gz 
 7 gunzip -c /tmp/fstab.gz > /list/gzip/fstab
 8 
 9 bzip2 -k -c /etc/fstab > /tmp/fstab.bz2
10 bzcat /tmp/fstab.bz2
11 bunzip2 -c /tmp/fstab.bz2 > /list/bzip2/fstab
12 
13 xz -c -k /etc/fstab > /tmp/fstab.xz
14 xzcat /tmp/fstab.xz
15 unxz -c /tmp/fstab.xz > /list/xz/fatab
16 
17 3.
18 tar jcvf /tmp/gzip.tar.bz2 *
19 tar Jcvf /tmp/xz.tar.xz *
20 tar zcvf /tmp/gz.tar.gz *
21 
22 tar jxvf /tmp/bzip2.tar.bz2 * -C /list/tat/bzip2
23 tar Jxvf /tmp/xz.tar.xz * -C /list/tat/xz
24 tar zxvf /tmp/gzip.tar.gz * -C /list/tat/gzip
View Code

Guess you like

Origin www.cnblogs.com/yanshicheng/p/12181218.html