Common commands for getting started with Linux-6. Linux backup and compression commands

Source: Internet
Author: User
Linux Backup and compression commands

TarCommand

Tar can create files and directories. Using tar, you can create a file (backup file) for a specific file, change the file in the file, or add a new file to the file. Tar was originally used to create files on tape. Now, you can create files, such as floppy disks, on any device. Using the tar command, you can package a large number of files and directories into one file, which is very useful for backing up files or combining several files into one file for network transmission. Tar on Linux is of the GNU version.

Syntax: Tar [primary option + secondary option] file or directory

When you use this command, the main option is required, and it tells tar what to do. The auxiliary option is used for assistance and can be used.

Main options:

C. Create a new archive file. Select this option if you want to back up a directory or some files.

R: append the file to the end of the file. For example, if you have prepared a backup file and find that there is still a directory or some files have forgotten to be backed up, you can use this option to append the directory or files you have forgotten to the backup file.

T list the file content and check which files have been backed up.

U updates the file. That is to say, replace the original backup file with the new file. If the file to be updated cannot be found in the backup file, append it to the end of the backup file.

X release a file from the file.

Auxiliary options:

B. This option is set for the tape drive. It is followed by a number to describe the block size. The default value is 20 (20*512 bytes ).

F. This option is usually required when you use an archive file or device.

K. Save the existing files. For example, if we restore a file, the same file will not be overwritten during restoration.

M sets the modification time of all files to the present when restoring files.

M creates a multi-volume archive file to store it on several disks.

V detailed report on the file information processed by tar. If this option is not available, tar does not report file information.

W each step requires confirmation.

Z uses gzip to compress/decompress the file. With this option, the file can be compressed. However, you must use this option to decompress the file during restoration.

 

GzipCommand

There are two obvious advantages to reduce the file size. One is to reduce the storage space, and the other is to reduce the transmission time when the file is transmitted over the network. Gzip is a frequently used command in Linux to compress and decompress files, which is convenient and easy to use.

Syntax: gzip [Option] compressed (decompressed) file name

Meaning of each option:

-C writes the output to the standard output and keeps the original file.

-D. decompress the compressed file.

-L the following fields are displayed for each compressed file:

Size of the compressed file

Size of uncompressed files

Compression Ratio

Uncompressed file name

-R recursively searches for the specified directory and compresses all the files or decompress the files.

-T test to check whether the compressed file is complete.

-V displays the file name and compression ratio for each compressed and decompressed file.

-Num uses the specified numeric num to adjust the compression speed.-1 or -- fast indicates the fastest compression method (low compression ratio), and-9 or -- best indicates the slowest compression method (high compression ratio ). The default value is 6.

 

UnzipCommand

How can I expand files compressed by WinZip in Microsoft Windows in Linux? You can use the unzipcommand to unexpand a compressed file named. Zip.

Syntax: unzip [Option] compressed file name. Zip

The meanings of each option are as follows:

-X file list: Decompress the file, but does not include the specified file.

-V.

-T whether the test file is damaged, but the pressure is not solved.

-D directory: Decompress the compressed file to the specified directory.

-Z only displays the annotation of the compressed file.

-N does not overwrite existing files.

-O overwrites existing files and does not require user confirmation.

-J. Do not recreate the directory structure of the document and decompress all the files to the same directory.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.