Directory
1. Introduction to Commands
2. Common parameter Introduction
3. Example
4. Direct access to the bottom
Introduction to Commands
The tar command is used to package or decompress a file, with the extension ". Tar", which specifies that specific parameters can be called gzip or bzip2 to make a compressed package or extract a compressed package with the extension ". tar.gz" or ". tar.bz2".
Back to Catalog
Common parameters Introduction
-c 建立新的压缩包-d 比较存档与当前文件的不同之处--delete 从压缩包中删除-r 附加到压缩包结尾-t 列出压缩包中文件的目录-u 仅将较新的文件附加到压缩包中-x 解压压缩包-C 解压到指定的目录-f 使用的压缩包名字,f参数之后不能再加参数-i 忽略存档中的 0 字节块-v 处理过程中输出相关信息-z 调用 gzip 来压缩归档文件,与 -x 联用时调用 gzip 完成解压缩-Z 调用 compress 来压缩归档文件,与 -x 联用时调用 compress 完成解压缩-j 调用 bzip2 压缩或解压-p 使用原文件的原来属性-P 可以使用绝对路径来压缩--exclude 排除不加入压缩包的文件
The TAR command-related package generally uses. tar as the file identification name. If the z parameter is added, the. tar.gz or. Taz represents the gzip compressed tar.
Back to Catalog
Instance
1. Package only, do not compress
[[email protected] ~]$ ls kernel linux study[[email protected] ~]$ tar -cvf study.tar study/ 压缩文件夹study/study/a.cstudy/b.txtstudy/a/study/a/a/study/a/d/[[email protected] ~]$ lskernel linux study
2. Package and use gzip compression
[[email protected] ~]$ lskernel linux study study.tar[[email protected] ~]$ tar -zcvf study.tar.gz study/ 使用 gzip 压缩study/study/a.cstudy/b.txtstudy/a/study/a/a/study/a/d/[[email protected] ~]$ lskernel linux study study.tar
3. Package and use BZIP2 compression
tar -jcvf study.tar.bz2 study/
4. View a list of compressed files
[[email protected] ~]$ lskernel linux study study.tar study.tar.gz[[email protected] ~]$ tar -ztvf study.tar.gz drwxrwxr-x hk/hk 0 2018-01-22 02:21 study/-rw-rw-r-- hk/hk 45 2017-12-31 00:00 study/a.c-rw-rw-r-- hk/hk 78 2018-01-08 06:09 study/b.txtdrwxrwxr-x hk/hk 0 2018-01-22 02:21 study/a/drwxrwxr-x hk/hk 0 2018-01-22 02:21 study/a/a/drwxrwxr-x hk/hk 0 2018-01-22 02:21 study/a/d/
5. Unzip the package to when the path
Back to Catalog
Linux commands (15) package or unzip the file tar