当前位置:首页>Linux>Linux07-Linux的压缩、打包、备份

Linux07-Linux的压缩、打包、备份

  • 2026-07-02 16:28:32
Linux07-Linux的压缩、打包、备份

一、压缩技术简介

文件太大,导致无法通过email发送,占用大量磁盘空间。这个时候压缩技术就派上用场了。

压缩技术原理

计算机系统中都是使用bytes单位来计量的,计算机中最小的计量单位是bit,1byte=8bits。如果要记录一个数字1,对应的比特(二进制)是:

00000001

1会在最右边占据1个bit,而其他7个bit都是0。在这个例子中,那7个bit应该是“空的”才对。

压缩就是通过一些复杂的计算方式,将这些没有使用到的空间‘丢’出来,以让文件占用的空间变小。

另外一种压缩技术,是将重复的数据进行统计记录。 举例来说,如果你的数据为'111....'共有100个1时, 那么压缩技术会记录为'100个1'而不是真的有100个1的位存在。

简单的说,你可以将他想成,其实磁盘里面有相当多的'空间'存在,并不是完全填满的, 而'压缩'的技术就是将这些'空间'填满,以让整个档案占用的容量下降! 不过,这些'压缩过的文件'并无法直接被我们的操作系统所使用的,因此, 若要使用这些被压缩过的文件,则必须将他'还原'回来未压缩前的模样, 那就是所谓的'解压缩'。

压缩与解压缩的好处:

  • 压缩过的文件容量变小了,占用更少的磁盘容量

  • 网络数据的传输中,由于数量量的降低,可以让网络带宽传输更多的数据。目前很多网站也利用文件压缩技术来进行数据的传送。你在网站上面看到的数据在经过网络传输时,使用的是‘压缩过的资料’,等到这些压缩过的资料到达你的计算机时,再进行解压缩。

二、Linux系统常见的压缩命令

2.1 gzip命令

gzip(GNU Zip)是 Linux/Unix 中最常用的文件压缩命令,主要用于压缩单个文件,压缩后的文件扩展名通常为 .gz

特点:

  • 只能压缩文件,不能直接压缩目录

  • 默认会删除原文件(保留压缩文件)

  • 压缩率较高,速度较快

  • 常与 tar 配合使用(.tar.gz 或 .tgz

命令语法 

gzip [选项] 文件gzip -r 目录

常用选项

选项长选项说明示例
-1--fast最快压缩,压缩率最低gzip -1 file
-2~-8不同压缩等级gzip -5 file
-9--best最大压缩率,速度最慢gzip -9 file
-d--decompress解压文件gzip -d file.gz
-k--keep保留原文件gzip -k file
-c--stdout输出到标准输出,不修改原文件gzip -c file > file.gz
-l--list查看压缩文件信息gzip -l file.gz
-r--recursive递归压缩目录中的文件gzip -r dir
-f--force强制覆盖gzip -f file
-t--test测试压缩文件是否损坏gzip -t file.gz
-v--verbose显示详细信息gzip -v file
-n--no-name不保存原文件名和时间gzip -n file
-N--name保存原文件名和时间gzip -N file

gzip、gunzip、zcat 的关系

命令功能是否删除 .gz 文件
gzip压缩默认删除原文件
gunzip解压默认删除 .gz 文件
gzip -d解压等同于 gunzip
zcat查看压缩文件内容不删除任何文件

gzip 压缩级别对比

级别参数压缩速度压缩率CPU 消耗适用场景
1-1最快最低最低实时日志、快速压缩
2~5-2~-5较快中等较低日常使用
6默认平衡较高中等默认推荐
7~8-7-8较慢较高较高备份、归档
9-9最慢最高最高长期存储、节省磁盘空间

命令演示

[root@localhost data]# ll | grep messages-rw-------1 root root    2621696月 3009:37 messages-rw-------1 root root    2621696月 3009:37 messages.bak[root@localhost data]# gzip messages[root@localhost data]# ll | grep messages          #压缩生成message.gz文件,源文件message被删除-rw-------1 root root    2621696月 3009:37 messages.bak-rw-------1 root root     379526月 3009:37 messages.gz[root@localhost data]#  ll | grep messages-rw-------1 root root    2621696月 3009:43 messages-rw-------1 root root    2621696月 3009:37 messages.bak-rw-------1 root root     379526月 3009:43 messages.gz[root@localhost data]# rm -rf messages.gz[root@localhost data]# gzip -k messages          #压缩生成message.gz文件,源文件message未被删除[root@localhost data]#  ll | grep messages-rw-------1 root root    2621696月 3009:43 messages-rw-------1 root root    2621696月 3009:37 messages.bak-rw-------1 root root     379526月 3009:43 messages.gz[root@localhost data]#[root@localhost data]# gzip -d messages.gz        #解压后,messages.gz文件被删除 gzip: messages already exists; do you wish to overwrite (y or n)? y[root@localhost data]#  ll | grep messages-rw-------1 root root    2621696月 3009:43 messages-rw-------1 root root    2621696月 3009:37 messages.bak[root@localhost data]# gzip -k messages[root@localhost data]#  ll | grep messages-rw-------1 root root    2621696月 3009:43 messages-rw-------1 root root    2621696月 3009:37 messages.bak-rw-------1 root root     379526月 3009:43 messages.gz[root@localhost data]# gzip -k -d messages.gz      #加上-k选项,解压缩不会删除压缩文件gzip: messages already exists; do you wish to overwrite (y or n)? y[root@localhost data]#  ll | grep messages-rw-------1 root root    2621696月 3009:43 messages-rw-------1 root root    2621696月 3009:37 messages.bak-rw-------1 root root     379526月 3009:43 messages.gz[root@localhost data]# gzip -t messages.gz         #无返回,说明压缩文件正常[root@localhost data]# echo $?0[root@localhost data]# gzip -v messages            #显示压缩过程 gzip: messages.gz already exists; do you wish to overwrite (y or n)? ymessages:        85.5% -- replaced with messages.gz[root@localhost data]# ls testdir/ -l总用量 780-rw-------1 root root 2621696月 3009:55 messages1-rw-------1 root root 2621696月 3009:55 messages2-rw-------1 root root 2621696月 3009:55 messages3[root@localhost data]# gzip -r -k testdir/[root@localhost data]# ls testdir/ -l总用量 900-rw-------1 root root 2621696月 3009:55 messages1-rw-------1 root root  379536月 3009:55 messages1.gz-rw-------1 root root 2621696月 3009:55 messages2-rw-------1 root root  379536月 3009:55 messages2.gz-rw-------1 root root 2621696月 3009:55 messages3-rw-------1 root root  379536月 3009:55 messages3.gz

gzip 与 tar 配合使用

[root@localhost data]# ls testdir/ -l总用量 780-rw-------1 root root 2621696月 3009:55 messages1-rw-------1 root root 2621696月 3009:55 messages2-rw-------1 root root 2621696月 3009:55 messages3[root@localhost data]# tar -cvzf testdir.tar.gz testdir             #打包并压缩目录testdirtestdir/testdir/messages3testdir/messages2testdir/messages1[root@localhost data]# ls | grep testtestdirtestdir.tar.gz    #生成的压缩文件[root@localhost data]# tar -xvf testdir.tar.gz                      #解包解压缩testdir/testdir/messages3testdir/messages2testdir/messages1[root@localhost data]# ls | grep testtestdirtestdir.tar.gz
参数作用
-c创建归档
-x解包
-z使用 gzip 压缩/解压
-f指定文件名
-v显示详细过程(可选)

2.2 bzip2命令

bzip2 是 Linux/Unix 中常用的文件压缩命令,采用 Burrows-Wheeler Transform (BWT) 压缩算法,相比 gzip压缩率更高,但压缩和解压速度更慢。压缩后的文件扩展名为 .bz2

[root@localhost data]# tar cvjf testdir.tar.bz2 testdirtestdir/testdir/messages3testdir/messages2testdir/messages1[root@localhost data]# ls -l | grep testdirdrwxr-xr-x 2 root root      40966月 3010:05 testdir-rw-r--r--1 root root     454526月 3011:22 testdir.tar.bz2-rw-r--r--1 root root    1138916月 3011:21 testdir.tar.gz[root@localhost data]# du -sh * | grep testdir    #通过对比,可以发现bz2的后的文件比gzip压缩的小很多784K    testdir48K     testdir.tar.bz2112K    testdir.tar.gz

特点:

  • 只能压缩单个文件,不能直接压缩目录(通常与 tar 配合使用)。

  • 默认会删除原文件,只保留 .bz2 文件。

  • 压缩率通常高于 gzip,但低于 xz

  • 常用于源码包、备份归档等场景。

命令语法

bzip2 [选项] 文件...

常用选项

选项长选项说明示例
-1--fast最快压缩,压缩率最低bzip2 -1 file
-2~-8不同压缩等级bzip2 -5 file
-9--best最高压缩率(默认)bzip2 -9 file
-d--decompress解压文件bzip2 -d file.bz2
-k--keep保留原文件bzip2 -k file
-c--stdout输出到标准输出bzip2 -c file > file.bz2
-f--force强制覆盖bzip2 -f file
-t--test测试压缩文件完整性bzip2 -t file.bz2
-v--verbose显示详细信息bzip2 -v file
-q--quiet安静模式bzip2 -q file

bzip2 工具家族

命令功能
bzip2压缩文件
bunzip2解压文件
bzcat查看压缩文件内容
bzip2recover尝试恢复损坏的 .bz2 文件

命令演示

[root@localhost data]# ls | grep messagesmessages1messages2[root@localhost data]# bzip2 messages1                   #默认压缩后,源文件被删除 [root@localhost data]# bzip2 -k messages2                #-k选项,压缩不删除源文件[root@localhost data]# ls | grep messagesmessages1.bz2messages2messages2.bz2[root@localhost data]# cp messages2 messages3[root@localhost data]# bzip2 -k -v messages3               #-v选项,显示详细过程   messages3:  7.600:1,  1.053 bits/byte, 86.84% saved, 262169in34497 out.[root@localhost data]# ls | grep messagesmessages1.bz2messages2messages2.bz2messages3messages3.bz2[root@localhost data]# bzip2 -t messages1.bz2          #测试压缩包是否被损坏[root@localhost data]# bzip2 -d messages1.bz2          #解压默认也删除压缩包文件[root@localhost data]# ls | grep messagesmessages1messages2messages2.bz2messages3messages3.bz2[root@localhost data]# rm -rf messages2[root@localhost data]# bunzip2 -k messages2.bz2         #解压时,加-k选项,保留压缩包[root@localhost data]# ls | grep messagesmessages1messages2messages2.bz2messages3messages3.bz2

与 tar 配合使用

由于 bzip2 不能直接压缩目录,因此通常配合 tar

打包并压缩目录

tar -cjf backup.tar.bz2 backup/

参数说明:

参数说明
-c创建归档
-j使用 bzip2 压缩
-f指定文件名

解压

tar -xjf backup.tar.bz2

2.3 xz命令

xz 是 Linux/Unix 中一种高压缩率文件压缩工具,采用 LZMA2(Lempel-Ziv-Markov chain Algorithm 2) 算法,在三者(gzipbzip2xz)中通常具有最高的压缩率,但压缩和解压速度相对较慢,CPU 和内存消耗也更高。

特点:

  • 只能压缩单个文件(压缩目录需配合 tar

  • 默认删除原文件,仅保留 .xz 文件

  • 压缩率最高,尤其适合大文件和长期归档

  • Linux 内核源码、许多发行版软件包都广泛使用 .tar.xz

命令语法

xz [选项] 文件...

常用选项

选项长选项说明示例
-0 ~ -9指定压缩级别(默认 -6xz -9 file
-e--extreme极限压缩模式(耗时更长)xz -9e file
-d--decompress解压xz -d file.xz
-k--keep保留原文件xz -k file
-c--stdout输出到标准输出xz -c file > file.xz
-f--force强制覆盖xz -f file
-t--test测试压缩包完整性xz -t file.xz
-l--list查看压缩包信息xz -l file.xz
-v--verbose显示详细信息xz -v file
-T0--threads=0使用全部 CPU 核心,默认是单线程xz -T0 file
-T2--threads=2使用 2 个线程xz -T2 file

命令演示

[root@localhost testdir]# lsmessages1  messages2  messages3[root@localhost testdir]# gzip -k messages1[root@localhost testdir]# bzip2 -k messages2[root@localhost testdir]# xz -k messages3[root@localhost testdir]# du -sh *       #三种压缩对比,xz的最小,其次是bz2260K    messages140K     messages1.gz260K    messages236K     messages2.bz2260K    messages332K     messages3.xz[root@localhost testdir]# rm -rf messages3.xz[root@localhost testdir]# xz -k -9 messages3[root@localhost testdir]# du -sh *260K    messages140K     messages1.gz260K    messages236K     messages2.bz2260K    messages332K     messages3.xz[root@localhost testdir]# rm -rf messages3.xz[root@localhost testdir]# xz  -k -T2 messages3       #指定2线程[root@localhost testdir]# xz -l messages3.xz   流      块     压缩大小     解压大小   比例  校验    文件名    1       1     30.0 KiB    256.0 KiB  0.117  CRC64   messages3.xz------------------------------------------------------------------------------------------------------| 字段           | 含义    || ------------ | ----- || Compressed   | 压缩后大小 || Uncompressed | 原始大小  || Ratio        | 压缩比   || Check        | 校验算法  || Filename     | 文件名   |-------------------------------------------------------------------------------------------------------[root@localhost testdir]# xz -v -k messages3messages3 (1/1)  100 %        30.0 KiB / 256.0 KiB = 0.117[root@localhost testdir]# rm -rf messages3[root@localhost testdir]# ll总用量 628-rw------- 1 root root 262169  6月 30 09:55 messages1-rw------- 1 root root  37953  6月 30 09:55 messages1.gz-rw------- 1 root root 262169  6月 30 09:55 messages2-rw------- 1 root root  34497  6月 30 09:55 messages2.bz2-rw------- 1 root root  30704  6月 30 09:55 messages3.xz[root@localhost testdir]# xz -d -k messages3.xz[root@localhost testdir]# ll总用量 888-rw------- 1 root root 262169  6月 30 09:55 messages1-rw------- 1 root root  37953  6月 30 09:55 messages1.gz-rw------- 1 root root 262169  6月 30 09:55 messages2-rw------- 1 root root  34497  6月 30 09:55 messages2.bz2-rw------- 1 root root 262169  6月 30 09:55 messages3-rw------- 1 root root  30704  6月 30 09:55 messages3.xz

与 tar 配合使用

打包并压缩目录

tar -cJf backup.tar.xz backup/

参数说明:

参数说明
-c创建归档
-J使用 xz 压缩
-f指定文件名

解压

tar -xJf backup.tar.xz

查看归档内容

tar -tJf backup.tar.xz
[root@localhost data]# tar -cvJf testdir.tar.xz testdir/testdir/testdir/messages3testdir/messages3.xztestdir/messages2testdir/messages1testdir/messages2.bz2testdir/messages1.gz[root@localhost data]# ll | grep testdirdrwxr-xr-x 2 root root      4096  7月  1 09:49 testdir-rw-r--r-- 1 root root    134172  7月  1 09:54 testdir.tar.xz[root@localhost data]# tar -tJf testdir.tar.xz      #查看压缩包中有什么文件testdir/testdir/messages3testdir/messages3.xztestdir/messages2testdir/messages1testdir/messages2.bz2testdir/messages1.gz[root@localhost data]# rm -rf testdir[root@localhost data]# tar -xvJf testdir.tar.xztestdir/testdir/messages3testdir/messages3.xztestdir/messages2testdir/messages1testdir/messages2.bz2testdir/messages1.gz[root@localhost data]# ll | grep testdirdrwxr-xr-x 2 root root      4096  7月  1 09:49 testdir-rw-r--r-- 1 root root    134172  7月  1 09:54 testdir.tar.xz

三、gzip、bzip2、xz 对比

特性gzipbzip2xz
扩展名.gz.bz2.xz
算法DEFLATEBWT + HuffmanLZMA2
压缩速度较慢最慢
解压速度很快较慢较慢(通常比压缩快)
压缩率较高最高
CPU 占用
内存占用
默认压缩级别696
是否支持多线程否(传统 gzip)支持(-T
是否支持目录

四、Linux系统打包命令-tar命令

tarTape Archive)是 Linux 中最常用的归档(打包)工具。它的主要作用是将多个文件或目录打包成一个归档文件,本身并不负责压缩;通常会与 gzipbzip2xz 等压缩工具配合使用,生成 .tar.gz.tar.bz2.tar.xz 等文件。

特点:

  • 可以打包单个文件、多个文件或整个目录。

  • 保留文件权限、所有者、时间戳、软链接等元数据。

  • 可与多种压缩算法结合。

  • 是 Linux 备份、软件发布和文件传输中最常用的工具之一。

4.1 tar工作原理

多个文件 ├── file1 ├── file2 └── file3      │      ▼   tar 打包      │      ▼ archive.tar        (仅归档,不压缩)      │      ▼gzip / bzip2 / xz      │      ▼archive.tar.gzarchive.tar.bz2archive.tar.xz

4.2 命令语法

tar [选项] 归档文件 [文件或目录]

4.3 常用选项

选项长选项作用
-c--create创建归档,打包文件(目录)
-x--extract解压归档
-t--list查看归档内容
-f--file指定归档文件
-v--verbose显示详细过程
-C--directory指定解压或打包目录
-z使用 gzip
-j使用 bzip2
-J使用 xz
-a--auto-compress自动识别压缩格式(GNU tar)
-p--preserve-permissions保留权限
-P--absolute-names保留绝对路径
--exclude排除文件或目录
--strip-components=N解压时去掉前 N 层目录
-k--keep-old-files不覆盖已有文件
--overwrite强制覆盖已有文件

4.4 命令演示

[root@localhost testdir]# ll总用量 784-rw------- 1 root root 262169  6月 30 09:55 messages1-rw------- 1 root root 262169  6月 30 09:55 messages2-rw------- 1 root root 262169  6月 30 09:55 messages3drwxr-xr-x 2 root root   4096  7月  1 14:39 test[root@localhost testdir]# ls testmessages1  messages2  messages3[root@localhost testdir]# tar -cvf message.tar messages1 messages2 messages3  #将三个文件打包到message.tar文件中messages1messages2messages3[root@localhost testdir]# ll总用量 1564-rw------- 1 root root 262169  6月 30 09:55 messages1-rw------- 1 root root 262169  6月 30 09:55 messages2-rw------- 1 root root 262169  6月 30 09:55 messages3-rw-r--r-- 1 root root 798720  7月  1 14:40 message.tardrwxr-xr-x 2 root root   4096  7月  1 14:39 test[root@localhost testdir]# tar -cvf test.tar test/     #打包目录,生成test.tar文件test/test/messages3test/messages2test/messages1[root@localhost testdir]# ll总用量 2344-rw------- 1 root root 262169  6月 30 09:55 messages1-rw------- 1 root root 262169  6月 30 09:55 messages2-rw------- 1 root root 262169  6月 30 09:55 messages3-rw-r--r-- 1 root root 798720  7月  1 14:40 message.tardrwxr-xr-x 2 root root   4096  7月  1 14:39 test-rw-r--r-- 1 root root 798720  7月  1 14:41 test.tar[root@localhost testdir]# tar -cvzf test.tar.gz test    #打包并使用 gzip 压缩test/test/messages3test/messages2test/messages1[root@localhost testdir]# tar -cvjf test.tar.bz2 test   #打包并使用 bzip2test/test/messages3test/messages2test/messages1[root@localhost testdir]# tar -cvJf test.tar.xz test     #打包并使用 xztest/test/messages3test/messages2test/messages1[root@localhost testdir]# ll总用量 2536-rw------- 1 root root 262169  6月 30 09:55 messages1-rw------- 1 root root 262169  6月 30 09:55 messages2-rw------- 1 root root 262169  6月 30 09:55 messages3-rw-r--r-- 1 root root 798720  7月  1 14:40 message.tardrwxr-xr-x 2 root root   4096  7月  1 14:39 test-rw-r--r-- 1 root root 798720  7月  1 14:41 test.tar-rw-r--r-- 1 root root  45245  7月  1 14:48 test.tar.bz2-rw-r--r-- 1 root root 113875  7月  1 14:48 test.tar.gz-rw-r--r-- 1 root root  30932  7月  1 14:48 test.tar.xz[root@localhost testdir]# mkdir test{1..4}            #创建4个目录[root@localhost testdir]# ll总用量 2552-rw------- 1 root root 262169  6月 30 09:55 messages1-rw------- 1 root root 262169  6月 30 09:55 messages2-rw------- 1 root root 262169  6月 30 09:55 messages3-rw-r--r-- 1 root root 798720  7月  1 14:40 message.tardrwxr-xr-x 2 root root   4096  7月  1 14:39 testdrwxr-xr-x 2 root root   4096  7月  1 14:51 test1drwxr-xr-x 2 root root   4096  7月  1 14:51 test2drwxr-xr-x 2 root root   4096  7月  1 14:51 test3drwxr-xr-x 2 root root   4096  7月  1 14:51 test4-rw-r--r-- 1 root root 798720  7月  1 14:41 test.tar-rw-r--r-- 1 root root  45245  7月  1 14:48 test.tar.bz2-rw-r--r-- 1 root root 113875  7月  1 14:48 test.tar.gz-rw-r--r-- 1 root root  30932  7月  1 14:48 test.tar.xz[root@localhost testdir]# tar -xvf test.tar -C test1   #解包test.tar文件到test1目录test/test/messages3test/messages2test/messages1[root@localhost testdir]# ls test1test[root@localhost testdir]# tar -xvzf test.tar.gz -C test2    #解压 .tar.gz到test2目录test/test/messages3test/messages2test/messages1[root@localhost testdir]# tar -xvjf test.tar.bz2 -C test3   #解压 .tar.bz2到test3目录test/test/messages3test/messages2test/messages1[root@localhost testdir]# tar -xvJf test.tar.xz -C test4  #解压 .tar.xz到test4目录test/test/messages3test/messages2test/messages1[root@localhost testdir]# ll总用量 1580-rw------- 1 root root 262169  6月 30 09:55 messages1-rw------- 1 root root 262169  6月 30 09:55 messages2-rw------- 1 root root 262169  6月 30 09:55 messages3-rw-r--r-- 1 root root 798720  7月  1 14:40 message.tardrwxr-xr-x 2 root root   4096  7月  1 14:39 testdrwxr-xr-x 3 root root   4096  7月  1 14:52 test1drwxr-xr-x 3 root root   4096  7月  1 14:55 test2drwxr-xr-x 3 root root   4096  7月  1 14:55 test3drwxr-xr-x 3 root root   4096  7月  1 14:56 test4[root@localhost testdir]# tar -cvzf /data/testdir/test1/test.tar.gz test   #指定压缩包文件的目录为指定目录test/test/messages3test/messages2test/messages1[root@localhost testdir]# ls test1/test  test.tar.gz[root@localhost testdir]# tar -tvzf test1/test.tar.gz    #查看压缩包内的文件drwxr-xr-x root/root         0 2026-07-01 14:39 test/-rw------- root/root    262169 2026-07-01 14:39 test/messages3-rw------- root/root    262169 2026-07-01 14:39 test/messages2-rw------- root/root    262169 2026-07-01 14:39 test/messages1[root@localhost testdir]#-----------------------------------------------------------------------------------------------[root@localhost testdir]# lstest1  test2  test3  test4[root@localhost testdir]# ls test1test  test.tar.gz[root@localhost testdir]# tar -tvzf test1/test.tar.gz        #查看压缩包内的文件drwxr-xr-x root/root         0 2026-07-01 14:39 test/-rw------- root/root    262169 2026-07-01 14:39 test/messages3-rw------- root/root    262169 2026-07-01 14:39 test/messages2-rw------- root/root    262169 2026-07-01 14:39 test/messages1[root@localhost testdir]# tar -xzvf test1/test.tar.gz test/messages1   #只解压message1文件出来test/messages1[root@localhost testdir]# lstest  test1  test2  test3  test4[root@localhost testdir]# ls testmessages1[root@localhost testdir]#----------------------------------------------------------------------------------------------------tar结合xz使用时,如何使用多线程,通过tar --use-compress-program,把 xz 的所有参数传给 tar命令----------------------------------------------------------------------------------------------------[root@localhost testdir]# tar -cvf test.tar.xz --use-compress-program="xz -T4" test1/testtest1/test/test1/test/messages3test1/test/messages2test1/test/messages1[root@localhost testdir]# lstest1  test2  test3  test4  test.tar.xz

4.5 GUN tar支持自动识别压缩格式

GNU tar 是 tar 命令的一个具体、也是最主流的实现版本。它由自由软件基金会(Free Software Foundation)开发和维护,相比最初的 tar,增加了许多强大的功能和扩展。

怎么确认自己使用的tar是不是GUN tar,通过tar --version命令查看版本,如果输出信息中明确包含 "GNU tar" 字样,那就可以确认是 GNU 版本。

[root@localhost testdir]# tar --versiontar (GNU tar) 1.34Copyright (C) 2021 Free Software Foundation, Inc.License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.This is free software: you are free to change and redistribute it.There is NO WARRANTY, to the extent permitted by law.由 John Gilmore 和 Jay Fenlason 所写。[root@localhost testdir]#[root@localhost testdir]# lstest[root@localhost testdir]# ls testmessages1  messages2  messages3[root@localhost testdir]# tar -cvaf test.tar.gz test    #根据压缩文件的后缀,自动选择对应的压缩技术test/test/messages3test/messages2test/messages1[root@localhost testdir]# file test.tar.gztest.tar.gz: gzip compressed data, from Unix, original size modulo 2^32 798720[root@localhost testdir]# tar -cvaf test.tar.bz2 testtest/test/messages3test/messages2test/messages1[root@localhost testdir]# file test.tar.bz2test.tar.bz2: bzip2 compressed data, block size = 900k[root@localhost testdir]# tar -cvaf test.tar.xz testtest/test/messages3test/messages2test/messages1[root@localhost testdir]# lstest  test.tar.bz2  test.tar.gz  test.tar.xz[root@localhost testdir]# file test.tar.xztest.tar.xz: XZ compressed data

GNU tar 支持根据文件后缀名自动选择合适的压缩技术进行解压缩或者压缩:

压缩:

tar -caf backup.tar.gz backup/tar -caf backup.tar.bz2 backup/tar -caf backup.tar.xz backup/

解压:

tar -xaf backup.tar.gztar -xaf backup.tar.bz2tar -xaf backup.tar.xz

4.6 压缩技术与tar结合使用总结

压缩格式创建解压查看
.tartar -cvftar -xvftar -tvf
.tar.gz / .tgztar -czvftar -xzvftar -tzvf
.tar.bz2tar -cjvftar -xjvftar -tjvf
.tar.xztar -cJvftar -xJvftar -tJvf
.tar.gz / .tgz或者.tar.bz2或者.tar.xz【GUN tar支持】tar -cvaftar -xvaftar -tvaf

五、dd命令

dd 是 Linux 中一个非常重要的底层数据复制工具,能够以块(Block)*为单位进行数据读写,可以在*文件、磁盘、分区、设备之间进行复制,因此常被称为 Linux 的底层拷贝命令

特点:

  • 可以复制文件、磁盘、分区、ISO 镜像等。

  • 可以进行磁盘备份、恢复、制作启动盘。

  • 可以转换数据格式(ASCII/EBCDIC、大小写转换等)。

  • 不依赖文件系统,可直接操作块设备。

  • 功能非常强大,但也非常危险,写错目标设备可能导致整个磁盘数据被覆盖。

5.1 dd工作原理

    输入(if)      │      ▼ 按块(Block)读取      │ 可进行格式转换(conv)      │      ▼ 按块(Block)写入      │      ▼    输出(of)

5.2 命令语法

dd if=<输入> of=<输出> [选项]

5.3 常用参数

参数含义示例
if=输入文件(Input File)if=/dev/sda
of=输出文件(Output File)of=backup.img
bs=块大小(Block Size)bs=1M
ibs=输入块大小ibs=4K
obs=输出块大小obs=4K
count=复制块数count=100
skip=跳过输入前 N 个块skip=1
seek=跳过输出前 N 个块seek=1
status=progress显示实时进度status=progress
conv=数据转换conv=sync,noerror

5.4 常见使用场景

5.4.1 复制普通文件,适合大文件或者块设备

dd if=file1 of=file2 bs=1M等价于cp file1 file2

命令演示:

[root@localhost testdir]# lsmessages1[root@localhost testdir]# dd if=messages1 of=messages1.bak bs=4k记录了64+1 的读入记录了64+1 的写出262169字节(262 kB,256 KiB)已复制,0.000703059 s,373 MB/s[root@localhost testdir]# ll总用量 520-rw------- 1 root root 262169  7月  1 15:37 messages1-rw-r--r-- 1 root root 262169  7月  1 16:51 messages1.bak[root@localhost testdir]# file messages1 messages1.bakmessages1:     UTF-8 Unicode text, with very long linesmessages1.bak: UTF-8 Unicode text, with very long lines

5.4.2 备份整个磁盘或者分区

dd if=/dev/sda of=/backup/sda.img bs=64M status=progressdd if=/dev/sda1 of=/backup/sda1.img bs=64M status=progress

说明:

  • 输入:整个 /dev/sda

  • 输出:镜像文件 sda.img

  • 如果sda是一块100G的磁盘,但是实际数据只有2G,那么生成的sda.img也是100G。因为 dd 是一个块级别的工具,它不关心磁盘上有没有数据,也不理解“文件”或“空余空间”的概念。

恢复:

dd if=/backup/sda.img of=/dev/sda bs=64M status=progress

警告: 恢复会覆盖目标磁盘上的所有数据。

命令演示:

/dev/sda1 分区挂载至/boot目录,备份sda1磁盘分区

[root@localhost ~]# df -h文件系统                       容量  已用  可用 已用% 挂载点devtmpfs                       4.0M     0  4.0M    0% /devtmpfs                          1.4G     0  1.4G    0% /dev/shmtmpfs                          550M  8.5M  542M    2% /run/dev/mapper/cs-root             17G   13G  4.2G   76% //dev/sda1                      960M  306M  655M   32% /boot/dev/mapper/vg--data-lv--data  482G  2.2G  455G    1% /datatmpfs                          275M   52K  275M    1% /run/user/42tmpfs                          275M   36K  275M    1% /run/user/0overlay                         17G   13G  4.2G   76% /var/lib/docker/overlay2/78d7b0b6180d813f3e5bf994ee34f909f954e622c1c711b02b86ed8135c0b2b6/mergedoverlay                         17G   13G  4.2G   76% /var/lib/docker/overlay2/71d01ad2b1415bebd28381f202e6cea925e5da109ea79f07a16188b6a5913404/mergedoverlay                         17G   13G  4.2G   76% /var/lib/docker/overlay2/0ed0a69af127b12c1992216ada97ac0fe073fa194ee55c8d441974ef7f7b2275/merged[root@localhost ~]# dd if=/dev/sda1 of=/data/sda1.img bs=64M status=progress402653184字节(403 MB,384 MiB)已复制,56 s,7.2 MB/s469762048字节(470 MB,448 MiB)已复制,159 s,3.0 MB/s1073741824字节(1.1 GB,1.0 GiB)已复制,424 s,2.5 MB/s记录了16+0 的读入记录了16+0 的写出1073741824字节(1.1 GB,1.0 GiB)已复制,424.494 s,2.5 MB/s[root@localhost ~]# cd /data/[root@localhost data]# du -sh sda1.img1.1G    sda1.img

5.4.3制作启动 U 盘

例如将 ISO 写入 /dev/sdb

dd if=ubuntu.iso of=/dev/sdb bs=4M status=progress oflag=sync

完成后执行:

sync

说明:

  • 目标应为整个磁盘设备(如 /dev/sdb),不要写成 /dev/sdb1

  • oflag=sync 和 sync 可确保数据完全写入。

5.4.4 生成测试文件&测试磁盘写性能

生成 1GB 文件:

dd if=/dev/zero of=test.img bs=1M count=1024 status=progress

参数解释:

参数
bs=1M每块 1MB
count=10241024 块

总大小:

1MB × 1024 = 1GB

命令演示:

[root@localhost data]# dd if=/dev/zero of=test.img bs=1M count=1024 status=progress993001472字节(993 MB,947 MiB)已复制,16 s,61.7 MB/s记录了1024+0 的读入记录了1024+0 的写出1073741824字节(1.1 GB,1.0 GiB)已复制,16.298 s,65.9 MB/s

5.4.5 测试磁盘读性能

dd if=test.img of=/dev/null bs=1G iflag=direct status=progress
[root@localhost data]# dd if=test.img of=/dev/null bs=1G iflag=direct status=progress1073741824字节(1.1 GB,1.0 GiB)已复制,2 s,557 MB/s记录了1+0 的读入记录了1+0 的写出1073741824字节(1.1 GB,1.0 GiB)已复制,1.92899 s,557 MB/s

5.4.6 清空磁盘

dd if=/dev/zero of=/dev/sdb bs=64M status=progress

将整个磁盘写为 0。

快速清除前 100MB:

dd if=/dev/zero of=/dev/sdb bs=1M count=100

5.5 conv 常见选项

选项作用
sync输入块不足时填充 0
noerror遇到读错误继续执行
notrunc不截断输出文件
fsync完成后刷新到磁盘

例如:

dd if=/dev/sda of=backup.img bs=64K conv=noerror,sync

适用于坏盘恢复,尽可能继续读取。

5.6 块大小(bs)选择

bs场景
512B扇区级操作
4K文件系统块
1M普通文件复制
4M写入 U 盘
64M大容量磁盘备份
1G性能测试

一般来说,适当增大 bs 可以减少系统调用次数,提高复制效率,但也会增加内存占用。

5.7 常用数据源

输入源说明
/dev/zero连续的 0
/dev/null空设备
/dev/random真随机数(速度较慢)
/dev/urandom伪随机数(速度较快)
/dev/sda整块磁盘
/dev/sda1分区
本文的pdf版本下载地址:Linux07-Linux的压缩打包备份.pdf

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-07-02 21:55:31 HTTP/2.0 GET : https://f.mffb.com.cn/a/502986.html
  2. 运行时间 : 0.350594s [ 吞吐率:2.85req/s ] 内存消耗:5,242.07kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=af24801108274dead6b328444341b99a
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000440s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000557s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000897s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.006163s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000677s ]
  6. SELECT * FROM `set` [ RunTime:0.009307s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000632s ]
  8. SELECT * FROM `article` WHERE `id` = 502986 LIMIT 1 [ RunTime:0.004650s ]
  9. UPDATE `article` SET `lasttime` = 1783000531 WHERE `id` = 502986 [ RunTime:0.001520s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 67 LIMIT 1 [ RunTime:0.015511s ]
  11. SELECT * FROM `article` WHERE `id` < 502986 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.016585s ]
  12. SELECT * FROM `article` WHERE `id` > 502986 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.015856s ]
  13. SELECT * FROM `article` WHERE `id` < 502986 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.047602s ]
  14. SELECT * FROM `article` WHERE `id` < 502986 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.071478s ]
  15. SELECT * FROM `article` WHERE `id` < 502986 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.054512s ]
0.354322s