Linux Basics-Unit Eighth Body processing commands and TAR commands

Source: Internet
Author: User
Tags bz2 unpack

Unit eighth body processing commands and TAR commands


Use the Cat command to merge files vertically
method of vertical merging of two kinds of documents
Archive and archive technology
purpose of Archiving
What is archive
functions of the tar command
common options for the tar command
Create, view, and extract archive files using the tar command
using the tar command to create an archive file
use the tar command to view an archive file
extracting an archive file using the tar command
file compression and decompression
What is compression
purpose of compression
What is decompression
gzip Command and Gunzip command
bzip2 Command and BUNZIP2 command
compress and decompress while using the TAR command
examples of usage of compression and decompression while using the tar command
homework after class
"Content of this section"
1. Using the cat command to merge files vertically
1) Master the vertical merging of files using the cat command:
A) For example: Use the cat command to vertically merge the three files of Baby.age, baby.kg, and baby.sex into a baby file:
Cat Baby.age baby.kg Baby.sex >baby
b) For example: Use the Cat command to add the contents of the Baby.age file to the Baby2 file:
Cat Baby.age >>baby2
2. Archive files and archiving technology (see Linux System Management P209)
1) Mastering the definition of archiving: Archiving (archiving) is the packaging of many files (or directories) into one file.
2) Understand the purpose of archiving: The purpose of archiving is to facilitate backup, restore and file transfer operations.
3) Master the function of the tar command: put multiple files (which may also include directories, because the directory itself is also a file) in a tape or disk archive file. And in the future, you can restore only some of the files specified in the archive as needed.
4) Master the common options for the tar command:
C: Create a new tar file.
T: Lists the contents of the directory in the tar file.
X: Extract the files from the tar file.
F: Specify the archive or tape (or possibly floppy) device (typically selected).
V: Displays the details of the packaged file, and V is the 1th letter of the verbose.
Z: Use the gzip compression algorithm to compress the packaged files.
J: Use the BZIP2 compression algorithm to compress the packaged file.
3. Create, view, and extract archive files using the tar command (see Linux System Management P210)
1) An example of using the TAR command to create an archive file:
Example: Use the TAR command to package the Arch directory as an archive file named Arch.tar (requires that all packaged files and directories be displayed):
Tar cvf Arch.tar Arch
For an example of using the TAR command to view an archive file:
For example, use the TAR command to display a method that arch.tar all the files in this archive file (package):
Tar tf Arch.tar
2) Master the use of the tar command to extract an archive file using an example:
For example, use the tar command to restore the entire contents of Arch.tar:
Tar xvf arch.tar-c Path

4. File compression and decompression (see Linux System Management P212)
1) Grasp the definition of compression: Compression is a large file through a number of compression algorithms into a small file.
2) Understand the purpose of compression: mainly to reduce the size of the file, which will save the disk or tape storage file space, and the transmission of these small files on the network will also reduce network browsing (that is, to save network bandwidth).
3) Mastering the definition of decompression: decompression is the way to restore a file that passes through some compression algorithms before it is compressed.
4) An example of the use of the gzip command and the Gunzip command:
A) For example: Compressed files File1 compressed into. gz format should use the command: gzip file1–c >/path/name.gz
b) For example: The command to extract the compressed file file1.gz is:
Gunzip file1.gz >
5) Use examples of mastering bzip2 commands and BUNZIP2 commands:
A) For example: Compress the file file1 into. bz2 format the command that should be used is: bzip2 file1 >
b) For example: The command to extract the compressed file file1.bz2 is:
BUNZIP2 file1.bz2 >
5. Compression and decompression while using the TAR command (see Linux System Management P214)
1) Master the use of compression and decompression while using the TAR command example
A) For example, use the TAR command to package the Arch catalog and use gzip technology to compress the packaged file (the packaged file is named arch.tar.gz):
Tar Cvfz arch.tar.gz Arch
b) For example: Use the TAR command to package the Arch directory and use bzip2 technology to compress the packaged file method (the packaged file is named arch.tar.bz2): Tar cvfj arch.tar.bz2 Arch

6. After-school assignments (spents 65 minutes)
1) Merge user information database files and group information database files vertically into one file/1.txt (overwrite)


2) Merge user information database files and user password database files vertically into one file/2.txt (append)


3) Package The/1.txt,/2.txt two files as a/1.tar


4) Use the gzip command to compress the 1.txt file named 1.txt.gz


5) Decompression 1.txt.gz


6) file name 1.txt.bz2 after compressing 1.txt compression with bzip2


7) Decompression 1.txt.bz2


8) Unpack 1.tar, unpack the file and store it in the/tmp directory


9) Use the TAR command to package and compress/1.txt,/2.txt, and get the file name 1.tar.gz


10) Unpack the 1.tar.gz, unpack the file and store it in the/tmp directory

Linux Basics-Unit Eighth Body processing commands and TAR commands

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.