Common Linux commands (5) -- compression and decompression commands
Last Update:2014-05-26
Source: Internet
Author: User
Common Linux commands (5) -- compression and decompression commands 1. command name: gzipwww.2cto.com execution permission: all users function description: compressed file syntax: gzip option [file] compressed format :. gzgzip can only compress files, but cannot compress directories ;...
Common Linux commands (5) -- compression and decompression commands 1. command name: gzip www.2cto.com execution permission: all users function description: compressed file syntax: gzip option [file] compressed format :. gz gzip can only compress files, but cannot compress directories. after gzip is compressed, the original file [root @ localhost abc] # lsafile issue is not retained. hard issue. soft prem test [root @ localhost abc] # gzip afile [root @ localhost abc] # lsafile.gz issue. hard issue. soft prem test [root @ localhost abc] #2. command name: gunzip execution permission: all users function description: decompressed. gz format compressed file syntax: gunzip option [compressed file] [root @ localhost abc] # gunzip afile.gz [root @ localhost abc] # lsafile issue. hard issue. soft prem test [root @ localhost abc] # or use: gzip-d to compress the file [root @ localhost abc] # lsafile.gz issue. hard issue. soft prem test [root @ localhost abc] # gzip-d afile.gz [root @ localhost abc] # lsafile issue. hard issue. soft prem test [root @ localhost abc] # www.2cto.com 3. command name: tar execution permission: all users function description: package directory syntax: tar [cvf] [Directory]-c .tar package file-v display details-f specifies the compressed file name-z package and compression format: .tar.gz package and compress the test Directory [root @ localhost abc] # tar-zcvf test.tar.gz testtest/[root @ localhost abc] # lsafile issue. hard issue. soft prem test test.tar.gz [root @ localhost abc] # package the adir directory first, then compress [root @ localhost abc] # tar-cvf adir.tar adiradir/[root @ localhost abc] # lsadir adir.tar afile issue. hard issue. soft prem test test.tar.gz [root @ localhost abc] # gzip adir.tar [root @ localhost abc] # lsadir adir.tar.gz afile issue. hard issue. soft prem test test.tar.gz [root @ localhost abc] # Use the tar command to decompress: -x unpackage .tar file-v display details-f specifies to extract the file-z decompress test.tar.gz [root @ localhost abc] # lsadir.tar.gz afile issue. hard issue. soft prem test.tar.gz [root @ localhost abc] # tar-zxvf test.tar.gz test/[root @ localhost abc] # lsadir.tar.gz afile issue. hard issue. soft prem test test.tar.gz [root @ localhost abc] # unpack adir.tar.gz [root @ localhost abc] # lsadir.tar.gz afile issue. hard issue. soft prem test test.tar.gz [root @ localhost abc] # gunzip adir.tar.gz [root @ localhost abc] # lsadir.tar afile issue. hard issue. soft prem test test.tar.gz [root @ localhost abc] # tar-xvf adir.tar 4. command name: zip execution permission: all users function description: compressed file or directory syntax: zip [-r] [compressed file name] [file or directory]-r compressed directory after compression format :. zip compression afile file [root @ localhost abc] # lsadir adir.tar afile issue. hard issue. soft prem test test.tar.gz [root @ localhost abc] # zip afile.zip afile adding: afile (stored 0%) [root @ localhost abc] # lsadir afile issue. hard prem test.tar.gzadir.tar afile.zip issue. soft test [root @ localhost abc] # compress the test Directory [root @ localhost abc] # lsadir afile issue. hard prem test.tar.gzadir.tar afile.zip issue. soft test [root @ localhost abc] # zip-r test.zip test adding: test/(stored 0%) [root @ localhost abc] # lsadir afile issue. hard prem test.tar.gzadir.tar afile.zip issue. soft test test.zip [root @ localhost abc] #5. command name: unzip execution permission: all users function description: decompressed. ZIP compressed file syntax: unzip [compressed file] decompress test.zip [root @ localhost abc] # unzip test.zip Archive: test.zip creating: test/[root @ localhost abc] #6. command name: bzip2 execution permission: function description of all users: compressed file syntax: bzip2 [-k] [file]-k. after a compressed file is generated, the original file is retained. Format :. bz2 can only compress files with a large compression ratio. it is suitable for compressing large files. afile [root @ localhost abc] # bzip2-k afile [root @ localhost abc] # lsadir afile afile.zip issue. soft test test.zipadir.tar afile.bz2 issue. hard prem test.tar.gz [root @ localhost abc] #7. command name: bunzip2 execution permission: all users function description: decompress file syntax: bunzip2 [-k] [compressed file]-k decompress the package and then retain the original file to decompress afile.bz2 [root @ localhost abc] # bunzip2-k afile.bz2 8. view the file type command file if you do not know the file type, you can use the file [root @ localhost abc] # file/etc/sysconfig: directory [root @ localhost abc] #