zip
Usage: Zip [options] files or directories that need to be compressed after the file name is compressed
Common options:
-q do not show compression procedure
-r Recursive processing, processing all files and subdirectories under the specified directory
-d Delete the specified file from the compressed file
-m After compressing the file and adding the compressed file, delete the original file, Move file to compressed file
-P Set password for compressed file (clear text)
-e Set Password for compressed file (hidden)
-D ZIP file does not establish directory name
-F try to fix a corrupted compressed file
-o to compress files that have the most recent change time in the file to be the same as that file
-g Compress files after attaching to existing compressed files, instead of creating new compressed files
-j Save only the file name and contents without any directory name
-u Replace newer files in compressed files
-z Add comments to compressed files
Instance:
1, a file file2 and a directory Dir2 compressed to test01.zip[[email protected] ~]# Zip -qr test01.zip file2 dir22, removing file2[[email protected] ~]# from compressed file test01.zip zip -d test01.zip file23, adding file3 to Compressed file Test01.zip (File3 automatically deleted after appending) [[email protected] ~]# zip -m test01.zip file34, compress a file file3 to File3.zip and set the password to hi[[email protected] ~]# zip -p hi file3.zip file3 [[email protected] ~]# zip -e file3.zip file3 //enter after entering the hidden password 5, the directory Dir1 and file3 compression, the name of Hi.zip and add comments content (content is This is a test) [[email protected] ~]# zip -zqr hi.zip dir1 file3 this is a test . //with "." End, enter
unzip
Common options:
-l Show files contained in compressed files
-v display files contained within a compressed file (more details)
-t Check that the compressed file is correct
-z Show only the memo text of the compressed file
-d Specify the directory to store after extracting the file
-x specifies which files in the. zip archive are not processed
-n do not overwrite the original file
-c file names in compressed files are case-sensitive
-J does not handle directory paths in compressed files
-l change all file names in compressed files to lowercase
instances:
[[email protected] ~]# unzip -l test.zip archive: test.zipthis is a test file. length date time name--------- ---------- ----- ---- 0 02-04-2015 03:13 hi/ 7 02-04-2015 03:13 hi/456 0 02-04-2015 03:12 hi/hello/ 10 02-04-2015 03:12 hi/hello/123    1702  02-04-2015 03:40   PASSWD--------- -- ----- 1719 5 files[[email protected] ~]# unzip -v test.zip archive: test.zipthis is a test file. length method Size Cmpr Date Time crc-32 name-------- ------ ------- ---- --------- - ----- -------- ---- 0 Stored 0 0% 02-04-2015 03:13 00000000 hi/ 7 Stored 7 0% 02-04-2015 03:13 f78ca403 hi/456 0 stored 0 0% 02-04-2015 03:12 00000000 hi/hello/ 10 stored 10 0% 02-04-2015 03:12 5dbe6fff hi/ hello/123 1702 defl:n 685 60%  02-04-2015 03:40 343C303D  PASSWD-------- ------- --- ------- 1719 702 59% 5 files[[email protected] ~]# unzip -t test.zip Archive: test.zipthis is a test file. testing: hi/ OK testing: hi/456 ok testing: hi/hello/ OK testing: hi/hello/123 ok testing: passwd okno errors detecTed in compressed data of test.zip. [[email protected] ~]# unzip -z test.zip archive: test.zipthis Is a test file. [[email protected] ~]#[[email protected] ~]# unzip -q test.zip -d /tmp/[[email protected] ~]# ls /tmp/hi passwd[[email protected] ~]# rm -rf /tmp/*[[email protected] ~]# unzip -q test.zip - D /tmp/ -x passwd[[email protected] ~]# ls /tmp/hi[[email protected] ~]# [[email protected] ~]# echo "One_1" > one[[ email protected] ~]# echo "Two_2" > two[[email protected] ~]# lsone two[[email protected] ~]# cat one twoone_1two_2[[email Protected] ~]# zip -q test.zip&nBsp;one two [[email protected] ~]# lsone test.zip two[[email protected] ~]# echo "One_new" > one[[email protected] ~]# echo "Two_new" > two[[email protected] ~]# unzip -q test.zip - X two replace one? [y]es, [n]o, [a]ll, [n]one, [r]ename: y[[email protected] ~]# lsone test.zip two[[email protected] ~]# cat one twoone_1two_new[[email protected] ~]#
Gzip/gunzip
Comment: Delete original file after default compression
Common options:
-r recursively handle all files and subdirectories under the specified directory
-t test compressed files correctly
-l listing information about files
-c retain original file
-n:1-9, specify compression ratio, default is 6
-d Extract compressed Files
-f forcibly compress the file, regardless of the file name or the existence of a hard connection, and whether the file is a symbolic connection
-n The original file name and time stamp are not saved when the file is compressed
-n Save the original file name and time stamp when compressing the file.
Instance:
[[EMAIL PROTECTED] ~]# LS -R.:123  INITTAB  ONE  PASSWD two./123:123 two./123/two:hi[[email protected] ~]# gzip -r 123 [[EMAIL PROTECTED] ~]# LS -R.:123  INITTAB  ONE  PASSWD two./123:123.gz two./123/two:hi.gz[[email protected] ~]# gzip one passwd [[email protected] ~]# ls 123 inittab one.gz passwd.gz two[[email protected] ~]# gzip -t one.gz [[email protected] ~]# ls123 inittab one.gz passwd.gz two[ [email protected] ~]# gzip -c inittab > inittab.gz[[email protected ] ~]# ls123 inittab inittab.gz one.gz passwd.gz two[[email protecteD] ~]# gzip -d one.gz passwd.gz [[email protected] ~]# ls123 inittab inittab.gz one passwd two[[email Protected] ~]#[[email protected]n ~]# lsinittab passwd[[email protected] ~]# gzip inittab passwd [[email protected] ~]# [[email protected ] ~]# lsinittab.gz passwd.gz[[email protected] ~]# [[email protected] ~]# [[email protected] ~]# [[email protected] ~]# lsinittab.gz passwd.gz[[email protected] ~]# gunzip -t inittab.gz passwd.gz [[ email protected] ~]# gunzip -l passwd.gz compressed uncompressed ratio uncompressed_name 789 1925 60.7% passwd[[ email protected] ~]# gunzip passwd.gz [[email protected] ~]# Lsinittab.gz passwd[[email protected] ~]# gunzip -c inittab.gz > inittab[[email protected] ~]# lsinittab inittab.gz passwd[[email protected] ~]#
Bzip2/bzcat
Common options:
-k compressed or uncompressed, Keep the original file
-t test the integrity of the compressed file
-d extract parameters
-c the compression and decompression results are sent to standard output
-f compression or decompression, if the output file has the same name as an existing file, forcibly overwrite
-z enforce compression
-n Compression Scale
instance:
[[Email protected] ~]# lsfile_1 file_2[[email protected] ~]# cat file_1 file_2file_one just one linefile_two just one line[[email protected] ~]# bzip2 file_1[[email protected] ~]# lsfile_1.bz2 file_2[[email protected] ~]# bzcat file_1.bz2 file_one just one line[[ email protected] ~]# bzip2 -d file_1.bz2 [[email protected] ~]# lsfile_1 file_2[[email protected] ~]# bzip2 -k file_1[[email protected] ~]# lsfile_1 file_1.bz2 file_2[[email protected] ~]# rm file_1rm: remove regular file ' file_1 '? y[[email protected] ~ ]# lsfile_1.bz2 file_2[[email protected] ~]# bzip2 -k -d file_1. Bz2 [[email protected] ~]# lsfile_1 file_1.bz2 file_2[[email protected] ~]#
XZ
Common options:
-k do not delete original file
-d Extract
-n compression ratio (1-9, default is 6)
instance:
[[email protected] ~]# lsfile_1 file_2[[email protected] ~]# xz file_1 [[email protected] ~]# lsfile_1.xz file_2[[email protected] ~]# lsfile_1 file_2[[email protected] ~]# xz file_1[[email protected] ~]# xz -k file_2[[email protected] ~ ]# lsfile_1.xz file_2 file_2.xz[[email protected] ~]# rm -rf file_2[[email protected] ~]# lsfile_1.xz file_2.xz[[email protected] ~]# xz -d file_1.xz [[email protected] ~]# xz -k -d File_2.xz [[email protected] ~]# lsfile_1 file_2 file_2.xz[[email protected] ~]#
tar
Common options:
-c Creating compressed Archives
 -F Use the file name, remember that this parameter is the last parameter, can only be followed by the file name
-t View
-z call gzip Properties
-j Call bzip2 property
-x extract
-r append file to the end of the compressed archive
-u update the files in the original package
--exclude file: Do not package the document during compression!
Instance:
tar -cf all.tar *.jpg all. jpg files into a package named All.tar tar -rf all.tar *.gif add all the. gif files to the All.tar package. -R is meant to increase the file. tar -uf all.tar logo.gif update the original tar package All.tar in the logo.gif file,-U is to indicate the meaning of the update file. tar -tf all.tar lists all of the files in the All.tar package,-T is the meaning of the file listed tar - xf all.tar extract all the files in the All.tar package,-X is the meaning of the decompression tar -czf jpg.tar.gz *.jpg pack all the JPG files in the directory into Jpg.tar and compress them in gzip to generate a gzip-compressed package named jpg.tar.gztar -cjf jpg.tar.bz2 *.jpg pack all the JPG files in the directory into Jpg.tar, and compress them with bzip2 to generate a bzip2 compressed package named JPG.TAR.BZ2TAR –CZF jpg.tar.Z *.jpg package All JPG files in the directory into jpg.tar and compress them with compress to generate a umcompress compressed package named Jpg.tar.Zrar jpg.rar *.jpg //rar format compression, you need to download the Rar for linux ,unrar e file.rar //decompression rar
This article is from the "Step Into the Linux World" blog, please be sure to keep this source http://linuxnote.blog.51cto.com/9876511/1635830
Common basic commands for Linux 14