Packaging and compression of Linux documents March 27 study notes

Source: Internet
Author: User
Tags date1

Packaging and compression of Linux documents

One, gzip: Compression tool

Gzip can only compress files, not compressed after the directory directly with the files to be compressed.

The file is compressed by default with a suffix name to distinguish what tool is compressed.

The source files will disappear after compression and decompression.


1. Compress passwd Files

[Email protected] cheng]# gzip passwd [[email protected] cheng]# lspasswd.gz


2, gzipz-d: Unzip the file

[Email protected] cheng]# gzip-d passwd.gz [[email protected] cheng]# LSPASSWD


3. Zcat: View the contents of the. GZ Compressed Package

View the files in the passwd.gz package

[Email protected] cheng]# zcat passwd.gz root:x:0:0:root:/root:/bin/bashbin:x:1:1:bin:/bin:/sbin/nologindaemon:x : 2:2:daemon:/sbin:/sbin/nologin

Two, bzip2 compression tool

The source file disappears after compression and decompression, and the suffix name used is. bz2.

Bzip2-z: Compressed files,-Z does not add can also be compressed, can only compress files

[Email protected] cheng]# bzip2 passwd [[email protected] cheng]# lspasswd.bz2


1, bzip2-d: Unzip the file

[Email protected] cheng]# bzip2-d passwd.bz2 [[email protected] cheng]# LSPASSWD


2, Bzcat: View the contents of the. bz2 compressed file

[Email protected] cheng]# Bzcat passwd.bz2 root:x:0:0:root:/root:/bin/bashbin:x:1:1:bin:/bin:/sbin/nologindaemon:x : 2:2:daemon:/sbin:/sbin/nologin


Three, XZ compression tool, this tool and gzip, bzip2 with the same

The suffix is using. xz.

The source file disappears after compression and decompression.


1. XZ Compressed file

[Email protected] cheng]# XZ passwd [[email protected] cheng]# LSPASSWD.XZ


2, xz-d: Unzip the file

[Email protected] cheng]# xz-d passwd.xz [[email protected] cheng]# LSPASSWD


3, Xzcat; view content in the. xz file

[Email protected] cheng]# Xzcat passwd.xzroot:x:0:0:root:/root:/bin/bashbin:x:1:1:bin:/bin:/sbin/nologindaemon:x : 2:2:daemon:/sbin:/sbin/nologin

Four, zip compression tool

Files compressed with the ZIP compression tool can be unpacked and opened in Windows.

Zip can compress the directory.

The source file does not disappear after the zip compress or unzip the file, that is, the destination file and the source file exist.


1. Compress files

Syntax: Zip [target file name] [source file]

[Email protected] cheng]# zip passwd.zip passwd adding:passwd (deflated 60%) [[email protected] cheng]# lspasswd passwd . zip

2. Compression directory

Syntax: zip-r [target file name] [source file]

[Email protected] cheng]# zip-r wang.zip Wang adding:wang/(stored 0) [[email protected] cheng]# lspasswd passwd.zip Wang Wang.zip


Multiple files can be compressed together

[[email protected] cheng]# zip a.zip Wang passwd adding:wang/(stored 0) adding:passwd (deflated 60%) [email protecte D] cheng]# lsa.zip passwd passwd.zip Wang Wang.zip

3, Unzip: unzip the file

[Email protected] cheng]# unzip Wang.zip Archive:wang.zip creating:wang/[[email protected] cheng]# lspasswd passwd. Zip Wang Wang.zip

4, unzip-d: Specify the decompression path

Antidote the Passwd.zip file to the/date1 directory

[Email protected] cheng]# unzip-d/date1/passwd.zip Archive:passwd.zip inflating:/date1/passwd [[Email Pro] Tected] cheng]# ls/date1passwd


5. Unzip-l: See what files are in the. zip file

[Email protected] cheng]# unzip-l a.zip archive:a.zip Length Date time Name-------------------------                     ---0 03-27-2015 22:38 wang/1791 03-27-2015 22:09 passwd----------------1791 2 files

Five, tar packaging tools

Tar can package a directory into a file that is easy to move or copy, and can be compressed while packaged.

Use syntax: tar [-ZJXCVFPP] source file

-Z: Simultaneous use of gzip compression

-j: Simultaneous use of bzip2 compression

-X: Unpacking or compressing

-T: View the files inside the tar package

-C: Build a tar package or zip file

-V: Visualize

-T: followed by the file name, compressed with "-F file name", meaning the compressed file filename, decompression with "-f filename", meaning is to extract filename. Note that if you have multiple parameter combinations with "-F", write "-F" to the last face.

-P: Use the properties of the original file to compress what properties to compress before compressing what properties. (not commonly used)

-P: Absolute path can be used. (not commonly used)


1. Packing

TAR-CVF B.tar passwd wang[[email protected] cheng]# TAR-CVF B.tar passwd wangpasswdwang/


2. Tar TVF B.tar: View the files in the B.tar package

[Email protected] cheng]# tar tvf b.tar-rw-r--r--root/root 10240 2015-03-27 23:35 passwddrwxr-xr-x root/root 0 2015-03-27 22:38 wang/

3. Unpacking

Tar xvf b.tar[[email protected] cheng]# tar xvf b.tar Passwdwang


3. Package and use gzip compression

TAR-ZCVF a.tar.gz passwd[[email protected] cheng]# TAR-ZCVF a.tat.gz passwd passwd[[email protected] cheng]# lsa.tat.gz passwd Wang[[email protected] cheng]#

Extract

TAR-ZXVF a.tat.gz

[[email protected] cheng]# TAR-ZXVF a.tat.gz passwd[[email protected] cheng]# lsa.tat.gz passwd wang[[email protected] cheng]#

4. Package and use BZIP2 compression

TAR-ZCVF a.tar.bz2 passwd

[[email protected] cheng]# TAR-JCVF a.tat.bz2 passwd passwd[[email protected] cheng]# lsa.tat.bz2 passwd wang[[email PR Otected] cheng]#

Extract

TAR-JXVF a.tat.gz

[[email protected] cheng]# TAR-XVF a.tar.bz2 passwd[[email protected] cheng]# lsa.tar.bz2 passwd wang[[email protected ] cheng]#


The usage of six 、--exclude

1. Filter files

Pack a directory, but there is a passwd file under the A directory, but I don't want him, use--exclude to filter out

[[email protected] wang]# TAR-CVF 1.tar--exclude "passwd" aa/a/b/[[email protected] wang]# tar TVF 1.tar drwxr-xr-x root /root 0 2015-03-28 00:14 a/drwxr-xr-x root/root 0 2015-03-28 00:13 a/b/

2. Filter Catalogue

[[email protected] wang]# TAR-CVF 2.tar--exclude "B" aa/a/passwd[[email protected] wang]# tar TVF 2.tar drwxr-xr-x root/ Root 0 2015-03-28 00:14 a/-rw-r--r--root/root 1791 2015-03-28 00:14 a/passwd[[email protected] wang]#


Seven, see a command belongs to that package

Yum provides "Vim"





Small white study notes, there are shortcomings, but also ask the big God to correct

Blog Address: http://www.aminglinux.com/bbs/thread-7671-1-1.html


This article is from the It Exchange Learning blog, so be sure to keep this source http://sxct168.blog.51cto.com/824373/1625866

Packaging and compression of Linux documents March 27 study notes

Related Article

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.