1. Command name: Gzip
Execution permission: All Users
Function Description: compress a file.
Syntax: gzip option [file]
Compressed Format:. GZ
Gzip can only compress files, but cannot compress directories;
The original file is not retained after gzip compression.
[Root @ localhost ABC] # lsafile issue. 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: Decompress a compressed file in the. GZ format.
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] #
3. Command name: Tar
Execution permission: All Users
Function Description: Package directory
Syntax: Tar [CVF] [Directory]
-C producer .tar package the file
-V: Show Details
-F: Specifies the compressed file name.
-Z package and compress
Compressed package 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 unpack the .tar File
-V: Show Details
-F: Specifies the file to be decompressed.
-Z Decompression
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: compresses a file or directory.
Syntax: Zip [-R] [compressed file name] [file or directory]
-R compression directory
Compressed Format:. Zip
Compress the afile [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] #
5Command name: unzip
Execution permission: All Users
Function Description: Decompress a. ZIP file.
Syntax: unzip [compressed file]
Decompress test.zip [root @ localhost ABC] # unzip test.zip archive: test.zip creating: Test/[root @ localhost ABC] #
6Command name: Bzip2
Execution permission: All Users
Function Description: compress a file.
Syntax: Bzip2 [-K] [file]
-K: the original file is retained after the compressed file is generated
Compressed Format:. bz2
Only files can be compressed
Large compression ratio, suitable for compressing large files
Compress 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] #
7Command name: bunzip2
Execution permission: All Users
Function Description: Decompress the file.
Syntax: bunzip2 [-K] [compressing files]
-K. decompress the package and keep the original file.
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: File
[Root @ localhost ABC] # file/etc/sysconfig: Directory [root @ localhost ABC] #