Linux operating system compression command related

  

Linux compressed file suffix name *.Z compress program compressed file; *.bz2 bzip2 program compressed file; *.gz gzip program compressed file; *.tar tar program packaged The data has not been compressed; the *.tar.gz tar package is packaged with gzip compression.

comm: Syntax: # compress [-d] filename Parameter Description: -d : Decompressed argument!

Example:

# compress man.config压缩# compress -d man.config.Z # uncompress man.config.ZUnzip gzip, zcat:

Syntax: # gzip [-d#] filename <==Compression and decompression # zcat filename.gz < ==Read compressed file content Parameter Description: -d : Decompressed parameter!

-# : Compression level, 1 worst, 9 best, 6 is the default!

Example: # gzip man.config will generate man.config.gz file # zcat man.config.gz will read out the contents of man.config # gzip -d man.config.gz # gunzip man.config.gz unzip Producing man.config This file -1 is the worst compression ratio, but the compression speed is the fastest, while -9 can achieve a better compression ratio (after compression, the file is smaller!), but it will lose some Speed! -6 is the default value bzip2, bzcat:

Syntax: # bzip2 [-dz] filename <==compression decompression command # bzcat filename.bz2 <== Read compressed file content command parameter description: -d : unzip -z : compression example: # bzip2 –z man.config compression # bzcat man.config.bz2 read # bzip2 –d man.config.bz2 # bunzip2 Man.config.bz2 unzip

tar:

Syntax: # tar [-zxcvfpP] filename # tar -N 'yyyy/mm/dd' /path -zcvf target.tar.gz Source parameter description: -z : Attribute with gzip -x: Unlock the parameter command of a compressed file -t : View the file inside tarfile -c : Set the parameter of a compressed file command -v : Display the file during compression -f : Use the file or folder name. Immediately after f, pick up the file or folder name. Do not add the parameter to write "tar -zcvPf tfile sfile". -p : Use the original attribute of the original file (the attribute will not Depending on the user)

-P : You can use the absolute path -N : Newer than the following date (yyyy/mm/dd) will be packaged into the newly created file —&mdash ;exclude FILE: Do not package FILE during compression!

Example: # tar -cvf dir The ectory.tar directory only consolidates the folder into a single file. # tar -zcvf directory.tar.gz directory In addition to packaging the folder, it is also compressed with gzip# tar -zcvf filename.tar.gz /home/test/* /home/test/The files in this folder are all packaged and compressed into a file named filename.tar.gz # tar -xvf directory.tar solves the tar packet because gzip is not used. Tar instead of .tar.gz), so just use –xvf! Don't need to add z, otherwise there will be problems!

# tar -zxvf directory.tar.gzThis is plus The result of gzip compression, so you need to add –z # tar –ztvf directory.tar.gz. This t can be used to view the file information in tar instead of unpacking it.

# tar -zcvPf home.tar.gz /home The file (clip) in the compressed file is an absolute path. Please note that when using this P parameter, do not add P after f, because After f, you must pick up the file name immediately.

# tar -N '2002/06/25' -zcvf home.tar.gz /home above says that in /home this folder, newer files than 2002/06/25 Will be packaged into the home.tar.gz file.

# tar -zcvf host.tar.gz /——exclude /mnt ——exclude /proc The above says that all the data in the root folder is packaged into host.tar.gz In the file, but /mnt and /proc are not packaged.

# tar -cvf - /home |  Tar -xvf – directly compresses and decompresses the pipeline command "pipe". In the above example, we want to "copy the data under /home directly to the current path, which is /root down", but feel that using cp -r is a bit of a hassle, then directly in this packaged way To package, where the - inside the command is to represent the packaged file. Since we don't want the transition file to exist, we copy it in this way.

cpio: Syntax: # cpio -covB > [file| Device]<==Backup # cpio -icduv < [file| Device]<==Restore parameter description: -o : Output data to file or device -i : Restore data from file or device to system -t : View file or device content created by cpio -c : A newer portable format way to store -v: display the file name during the backup process on the screen -B: Let the default Blocks increase to 5120 bytes, the default is 512 bytes. This has the advantage of allowing large files to be stored. Speed ​​up.

-d : Automatically create a folder, because the content of cpio may not be in the same folder, so there will be problems in the process of anti-backup! This time with -d, it can be automatic Set up the required directories!

-u : Update, overwrite old files with newer files: # find /-print |  Cpio -covB > /dev/st0 saves the found file to the storage device # cpio -icduv < /dev/st0 restores the data of the storage device back!

# cpio -icdvt < /dev /st0 > /tmp/content dumps the contents of the storage device (file name only) to /tmp/content # find /-type -f |  Cpio -o > /tmp/root.cpio # cpio -i < /tmp/root.cpio first output to /tmp/root.cpio this file, then restore it back to him!

Copyright © Windows knowledge All Rights Reserved