4. Document compression and decompression operations
Common compressed files in Linux are: *.tar.gz, *.tgz, *.gz, *. Z, *bz2 and so on. The compression and decompression commands for each of the different compressed files are also different.
The *.tar.gz:tar program is packaged in a document and is compressed by gzip.
The data that is packaged by the *.tgz:tar program is not compressed. Note: Tar is a wrapper that can package multiple documents into one document
The *.gz:gzip program compresses the document.
*. The Z:compress program compresses the document.
The *.bz2:bzip program compresses the document.
1). Compress: It is used to package documents or directories into *. Z type of document or unzip *. File of type Z. Note: The Linux system rarely comes with compress programs, you need to install the Compress program to use this command, to understand the good
Command line: Compress [-d][-d][-r] Document
[-d]: Used to unzip the file operation.
[-R]: can also be compressed together with the document under the directory.
[-c]: Output compressed data to the screen.
The [-C] property allows you to output file-compressed data to another compressed file. Keep the original file.
Example: Compress-c./test/file1 >./test/file1. Z//There will be two files under test, one is the File1 document, and the other is file1. Z Compress the document.
Note: the ' > ' symbol is a data flow redirector that redirects data that was originally to be output to a screen into a document.
2). Gzip and Zcat: Files that are used to package a document or directory into a *.gz type of document or to decompress a *.gz type. Note: *. Z's files can also be decompressed by gzip.
Command line: GIZP [-c][-d][-t][-0~9] Document
[-c]: Output compressed data to the screen. Note: It is also possible to use the same method as compress, which preserves the original document and creates a new compressed document.
[-d]: Used to unzip the file operation.
[-T]: used to verify the consistency of the compressed document, to see if the document is error-free.
[ -0~9]: compression level. [-1]: the fastest, but the worst compression ratio. [-9]: the fastest, but the best compression ratio. The preset is [-6].
Zcat: An instruction to read the contents of a compressed document without extracting the compressed file.
3). bzip2 and Zbcat: Files that are used to package a document or directory into a *.bz2 type of document or to decompress a *.bz2 type.
Command line: bzip2 [-c][-d][-z][-0~9] Document
[-c]: Output compressed data to the screen. Note: It is also possible to use the same method as compress, which preserves the original document and creates a new compressed document.
[-d]: Used to unzip the file operation. Note: Multiple types of compressed files can be decompressed by the bzip-d command:. BZ,. bz2,. tbz,. TBZ2, etc.
[-Z]: Compressed parameters.
[ -0~9]: compression level. [-1]: the fastest, but the worst compression ratio. [-9]: the fastest, but the best compression ratio. The preset is [-6].
Zbcat: An instruction to read the contents of a compressed document without extracting the compressed file.
4). Methods in Tar:1-3 the compression of a document, the Tar method can package a document or directory into a file, and the packaged file *.tar. Note: This command can also be used to back up
Command line: Tar [-c][-x][-t][-z][-j][-v][-f][-p][-p][-n] [-exclude] File or directory
[-c]: Create a packaged file.
[-X]: Unzip a packaged file.
[-T]: see what files are in the *.tar file. -c.-x.-t can only have one attribute at a time, because packaging, unpacking, and viewing a packaged file cannot be done at the same time.
[-Z]: gzip compress the packaged files. Generally used in conjunction with [-c].
[-J]: The packaged files are bzip2 compressed. Generally used in conjunction with [-c].
[-V]: Displays the document in a compressed process. Generally used with [-c], [-z], or [-j].
[-F]: Use file name. When executed with other attributes, it must be at the end. F is followed by the file name that is displayed when the document is packaged or compressed.
Example: TAR-CZVF./test.tar.gz./test//package All files under the TEST directory and compress them into TEST.tar.gz files and display the document.
[-P]: Using the original file's original properties, will not be based on the user's different changes.
[-P]: The absolute path can be used for compression.
[-n]: date followed by, only documents that are newer than this date are packaged. When we back up the file, if it was previously backed up, but now only need to back up the new file, you can pass this property.
[-exclude]: followed by the file name, meaning that all files except this file are packaged.
Example: Tar-exclude./TEST/FILE1-CZVF TEST.tar.gz./test//To package and compress all other files except/test files in the. file1 file into a TEST.tar.gz file.
5. File system operation //Here is only a brief explanation of the file system, I mainly need to mount a USB flash drive.
1). DF: The main display system on the file system//Through this command can view the USB flash drive
Command line: DF [-h] [directory or file name]
[h]: Displays data for each file system in a concise manner.
2). FDISK: Disk Partitioning
Command line: fdisk [-l] [appliance name]
[-l]: can view all the devices
[Device name]: Enter the specified device, can be set.
3). Mount: Disk Mount
Command line: Mount device name mount point
Mount the USB drive step: Do not plug the USB flash drive to the FDISK command to see the existing device, and then plug in the USB stick, see the name of the more out of the device. Then create the hold point Mkdir/mnt/usb. The USB stick is then mounted to the/MNT/USB via MOUNT/DEV/SDA/MNT/USB. You can then manipulate the contents of the USB drive through the/MNT/USB directory.
4). Umount: Disk Offload
Command line: Umount Appliance name or mount point
Uninstall the USB stick directly using UMOUNT/DEV/SDA or UMOUNT/MNT/USB can.
Linux Common Document Operations Command--2