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] #