Linux command - tar unzip command

1.tar.gz tar.bz2 tar.xf
2.gzip
3.zip
4.zcat

data +%F #Package name contains current time

Commonly used commands:
1.tar packaging compression
packaging:
tar czf dir1.tar.gz dir1

Decompression: ####### tar decompression will overwrite the existing directory. Before decompression, rename the original directory and back it up ############
tar xf dir1.tar.gz #can be decompressed tar.gz tar.bz2 tar.xz

View the contents of the compressed package
tar tf dir1.tar.gz


1. tar:
packaging:
tar -czf dir20190101.tar dir

Unzip:
tar xf dir20190101.tar

View the contents of the package
tar tf dirdir20190101.tar

tar.gz format of
the tar command to archive, gzip compressed into tar.gz
how to package
tar czf dir1.tar.gz dir1
commonly packaged with a combination of compression:
CZF package # unpack tar.gz format: zxf
CJF # packing tar.bz Format decompression: jxf
cJf #Pack tar.xz format decompression:

xf: Automatically select the decompression mode (usually use this decompression)

如何解压
tar xf dir1.tar.gz

Options:
c: Transcend the new archive file
z: Compress with gzip, suffix tar.gz
x: Unpack the archive file
t: List the file list in the archive file
f: Specify the package name, multi-parameter f write the last
j: Use bzip2 to compress the archive, suffix tar.bz
J: uppercase J, xz compressed archive, suffix tar.xz
C: big C, specify the location of the decompression directory
X: exclude multiple files (write the name of the file to be excluded)
h: package Soft link
--exclude: exclude files that do not need to be packaged
--exclude /etc/passwd /etc/shadow


2. gzip #Use compression when compressing a single file
:
gzip file #Compress the file, the original file will be deleted after compression

Unzip:
gzip -d file #Unzip, the original compressed package will be deleted

Usage scenarios:
1. When you need to make a configuration file not effective,
gzip CentOS-Base.repo
If you want to view the content inside, use zacat
zcat CentOS-Base.repo

2.把当前目录下所有文件都打包
    gzip *          #每个文件都会单独打成一个包

3. zip, compress files and directories (does not delete source files)
install zip
yum install zip unzip -y
parameter:
-r: recursively package all contents in the directory

如何压缩文件
zip 压缩包名    要打包的文件
zip file.zip    file.log

如何压缩目录
zip -r dir.zip /dir

如何解压
unzip 包名.zip

测试是否能与windows之间相互解压

4.zcat #View the content of the file in the compressed package
zcat file.gz #View the compressed content of gz

Guess you like

Origin blog.51cto.com/paitoubing/2544470