压缩与打包

目录

一、压缩打包介绍

二、gzip压缩工具

三、bzip2压缩工具

四、xz压缩工具

五、zip压缩工具

六、tar打包

七、打包并压缩


一、压缩打包介绍

使用压缩工具的好处:对文件进行压缩,使得原文件的体积减小,尤其是对文本文件,压缩后大大减小。这样既节省了磁盘,又有利用网络传输,这对于当年磁盘以M为单位的时候来说是极具意义的。哪怕在当前,也是很有意义,因为 一般使用的都是不对称宽带,100M下行的宽带,上行可能只有2M。压缩后的文件有利用加快网络传输。

Linux下最常见的压缩文件格式:.zip,.gz,.bz2,.xz。


二、gzip压缩工具

语法:gzip [选项] filename

gzip不能压缩目录。默认压缩级别是6

压缩文件

[root@localhost ~]# du -sh sys.log
6.2M	sys.log
//压缩文件
[root@localhost ~]# gzip sys.log
//默认压缩后原文件消失,只剩下压缩文件
[root@localhost ~]# ll
total 7108
-rw-r--r--. 1 root root    2534 May 28 04:20 1.txt
-rw-r--r--. 1 root root 7023391 May 28 04:22 7lines-top.png.gz
-rw-------. 1 root root    1313 May 26 05:56 anaconda-ks.cfg
drwxr-xr-x. 2 root root      69 May 26 09:09 demo
drwxr-xr-x. 2 root root       6 May 26 07:25 python
drwxr-xr-x. 2 root root       6 May 26 07:25 sh
-rw-r-----. 1 root root  243872 May 28 04:25 sys.log.gz
//压缩后大不240k
[root@localhost ~]# du -sh sys.log.gz
240K	sys.log.gz
//指定压缩文件路径,且保留原文件
[root@localhost ~]# gzip -c sys.log > /tmp/sys.log.gz
[root@localhost ~]# ls
1.txt  7lines-top.png.gz  anaconda-ks.cfg  demo  python  sh  sys.log
[root@localhost ~]# du -sh /tmp/sys.log.gz 
240K	/tmp/sys.log.gz

解压缩

//gizp -d选项解压缩
[root@localhost ~]# gzip -d sys.log.gz
[root@localhost ~]# ls
1.txt  7lines-top.png.gz  anaconda-ks.cfg  demo  python  sh  sys.log
//gunzip解压
[root@localhost ~]# gzip sys.log 
[root@localhost ~]# ls
1.txt  7lines-top.png.gz  anaconda-ks.cfg  demo  python  sh  sys.log.gz
[root@localhost ~]# gunzip sys.log.gz
[root@localhost ~]# ls
1.txt  7lines-top.png.gz  anaconda-ks.cfg  demo  python  sh  sys.log
//解压sys.log.gz到指定目录,并且原文件保留,
[root@localhost ~]# gzip -d -c /tmp/sys.log.gz > ./demo/sys.log
[root@localhost ~]# ls -l /tmp/sys.log.gz 
-rw-r--r--. 1 root root 243872 May 28 04:34 /tmp/sys.log.gz
[root@localhost ~]# ls -l ./demo/sys.log 
-rw-r--r--. 1 root root 6422528 May 28 04:38 ./demo/sys.log
//解压sys.log.gz到指定目录,并且原文件保留,
[root@localhost ~]# rm -f ./demo/sys.log 
[root@localhost ~]# gunzip -c /tmp/sys.log.gz > ./demo/sys.log
[root@localhost ~]# ls -l /tmp/sys.log.gz 
-rw-r--r--. 1 root root 243872 May 28 04:34 /tmp/sys.log.gz
[root@localhost ~]# ls -l ./demo/sys.log 
-rw-r--r--. 1 root root 6422528 May 28 04:41 ./demo/sys.log

查看gz压缩文件

[root@localhost ~]# zcat /tmp/sys.log.gz | more
LPKSHHRH

......下略

查看gz文件属性

[root@localhost ~]# file /tmp/sys.log.gz 
/tmp/sys.log.gz: gzip compressed data, was "sys.log", from Unix, last modified: Mon May 28 04:25:26 2018

三、bzip2压缩工具

语法:bzip2 [-dz] filename

bzip2的比gzip厉害,但是速度相对来说慢一点。

bzip2默认压缩级别9,bzip2也无法压缩目录。

压缩文件

[root@localhost ~]# bzip2 sys.log 
//压缩后原文件也是消失的。生成.bz2的文件
[root@localhost ~]# ll
total 7084
-rw-r--r--. 1 root root    2534 May 28 04:20 1.txt
-rw-r--r--. 1 root root 7023391 May 28 04:22 7lines-top.png.gz
-rw-------. 1 root root    1313 May 26 05:56 anaconda-ks.cfg
drwxr-xr-x. 2 root root      83 May 28 04:41 demo
drwxr-xr-x. 2 root root       6 May 26 07:25 python
drwxr-xr-x. 2 root root       6 May 26 07:25 sh
-rw-r-----. 1 root root  220221 May 28 04:25 sys.log.bz2
//压缩文件且指定路径,原文件存在
[root@localhost ~]# bzip2 -c sys.log > /tmp/sys.log.bz2
[root@localhost ~]# ls -l /tmp/sys.log.bz2 
-rw-r--r--. 1 root root 0 May 28 05:04 /tmp/sys.log.bz2
[root@localhost ~]# ll ./sys.log 
-rw-r-----. 1 root root 6422528 May 28 04:25 ./sys.log

解压缩

[root@localhost ~]# bzip2 -d sys.log.bz2 
[root@localhost ~]# ll
total 13140
-rw-r--r--. 1 root root    2534 May 28 04:20 1.txt
-rw-r--r--. 1 root root 7023391 May 28 04:22 7lines-top.png.gz
-rw-------. 1 root root    1313 May 26 05:56 anaconda-ks.cfg
drwxr-xr-x. 2 root root      83 May 28 04:41 demo
drwxr-xr-x. 2 root root       6 May 26 07:25 python
drwxr-xr-x. 2 root root       6 May 26 07:25 sh
-rw-r-----. 1 root root 6422528 May 28 04:25 sys.log
//指定压缩路径,且保留原文件
[root@localhost ~]# bzip2 -d -c sys.log.bz2 > /tmp/sys.log1
[root@localhost ~]# ls -l /tmp/sys.log1
-rw-r--r--. 1 root root 6422528 May 28 04:53 /tmp/sys.log1
[root@localhost ~]# ls ./sys.log.bz2 
./sys.log.bz2

**查看bzip2压缩文件内容

[root@localhost ~]# bzcat sys.log.bz2 | more
LPKSHHRH









 Ԃ
......下略

查看bzip2文件属性

[root@localhost ~]# file sys.log.bz2 
sys.log.bz2: bzip2 compressed data, block size = 900k

四、xz压缩工具

语法: xz [-zd] filename

xz文件压缩效果好,但是速度慢,默认压缩级别6,且也不能压缩目录

压缩

[root@localhost ~]# xz sys.log 
//压缩后原文件消失
[root@localhost ~]# ll
total 7036
-rw-r--r--. 1 root root    2534 May 28 04:20 1.txt
-rw-r--r--. 1 root root 7023391 May 28 04:22 7lines-top.png.gz
-rw-------. 1 root root    1313 May 26 05:56 anaconda-ks.cfg
drwxr-xr-x. 2 root root      83 May 28 04:41 demo
drwxr-xr-x. 2 root root       6 May 26 07:25 python
drwxr-xr-x. 2 root root       6 May 26 07:25 sh
-rw-r-----. 1 root root  169588 May 28 04:25 sys.log.xz

解压缩

[root@localhost ~]# xz -d sys.log.xz 
[root@localhost ~]# ll
total 8856
-rw-r--r--. 1 root root    2534 May 28 04:20 1.txt
-rw-r--r--. 1 root root 7023391 May 28 04:22 7lines-top.png.gz
-rw-------. 1 root root    1313 May 26 05:56 anaconda-ks.cfg
drwxr-xr-x. 2 root root      83 May 28 04:41 demo
drwxr-xr-x. 2 root root       6 May 26 07:25 python
drwxr-xr-x. 2 root root       6 May 26 07:25 sh
-rw-r-----. 1 root root 6422528 May 28 04:25 sys.log
//指定压缩路径,源文件保留
[root@localhost ~]# xz -c sys.log > /tmp/sys.log.xz
[root@localhost ~]# ll ./sys.log 
-rw-r-----. 1 root root 6422528 May 28 04:25 ./sys.log
[root@localhost ~]# ll /tmp/sys.log.xz 
-rw-r--r--. 1 root root 169588 May 28 05:07 /tmp/sys.log.xz

解压缩

[root@localhost ~]# ll
total 7036
-rw-r--r--. 1 root root    2534 May 28 04:20 1.txt
-rw-r--r--. 1 root root 7023391 May 28 04:22 7lines-top.png.gz
-rw-------. 1 root root    1313 May 26 05:56 anaconda-ks.cfg
drwxr-xr-x. 2 root root      83 May 28 04:41 demo
drwxr-xr-x. 2 root root       6 May 26 07:25 python
drwxr-xr-x. 2 root root       6 May 26 07:25 sh
-rw-r-----. 1 root root  169588 May 28 04:25 sys.log.xz
[root@localhost ~]# xz -d sys.log.xz 
[root@localhost ~]# ll
total 8856
-rw-r--r--. 1 root root    2534 May 28 04:20 1.txt
-rw-r--r--. 1 root root 7023391 May 28 04:22 7lines-top.png.gz
-rw-------. 1 root root    1313 May 26 05:56 anaconda-ks.cfg
drwxr-xr-x. 2 root root      83 May 28 04:41 demo
drwxr-xr-x. 2 root root       6 May 26 07:25 python
drwxr-xr-x. 2 root root       6 May 26 07:25 sh
-rw-r-----. 1 root root 6422528 May 28 04:25 sys.log
//解压到指定目录并改名
[root@localhost ~]# xz -d -c sys.log.xz > ./demo/sys.log 
[root@localhost ~]# ls -l ./demo/sys.log 
-rw-r--r--. 1 root root 6422528 May 28 05:09 ./demo/sys.log

查看xz文件属性

[root@localhost ~]# file sys.log.xz 
sys.log.xz: XZ compressed data

三种压缩工具的对比

[root@localhost ~]# gzip -c sys.log > /tmp/sys.log.gz
[root@localhost ~]# bzip2 -c sys.log > /tmp/sys.log.bzip2 
[root@localhost ~]# xz -c sys.log > /tmp/sys.log.xz
[root@localhost ~]# du -sh /tmp/sys.log.*
216K	/tmp/sys.log.bzip2
240K	/tmp/sys.log.gz
168K	/tmp/sys.log.xz
//可见xz的压缩率gzip < bzip2 < xz,但是压缩效果越好,耗时越长。 

五、zip压缩工具

zip可以压缩文件或目录,且zip文件格式也可以在windows下使用

zip的默认压缩级别6。

压缩文件

//压缩文件
[root@localhost ~]# zip sys.log.zip sys.log 
  adding: sys.log (deflated 96%)
[root@localhost ~]# ll
total 9096
-rw-r--r--. 1 root root    2534 May 28 04:20 1.txt
-rw-r--r--. 1 root root 7023391 May 28 04:22 7lines-top.png.gz
-rw-------. 1 root root    1313 May 26 05:56 anaconda-ks.cfg
drwxr-xr-x. 2 root root      83 May 28 04:41 demo
drwxr-xr-x. 2 root root       6 May 26 07:25 python
drwxr-xr-x. 2 root root       6 May 26 07:25 sh
-rw-r-----. 1 root root 6422528 May 28 04:25 sys.log
-rw-r--r--. 1 root root  244010 May 28 05:26 sys.log.zip
//压缩文件和目录
[root@localhost ~]# zip -r etc.zip syslog /etc
zip warning: name not matched: syslog
  adding: etc/ (stored 0%)
  adding: etc/fstab (deflated 40%)
  adding: etc/crypttab (stored 0%)
......中间略
  adding: etc/locale.conf (stored 0%)
  adding: etc/hostname (deflated 5%)
  adding: etc/resolv.conf (deflated 2%)
  adding: etc/aliases.db (deflated 93%)
[root@localhost ~]# ll
total 18280
-rw-r--r--. 1 root root    2534 May 28 04:20 1.txt
-rw-r--r--. 1 root root 7023391 May 28 04:22 7lines-top.png.gz
-rw-------. 1 root root    1313 May 26 05:56 anaconda-ks.cfg
drwxr-xr-x. 2 root root      83 May 28 04:41 demo
-rw-r--r--. 1 root root 9402908 May 28 05:28 etc.zip
drwxr-xr-x. 2 root root       6 May 26 07:25 python
drwxr-xr-x. 2 root root       6 May 26 07:25 sh
-rw-r-----. 1 root root 6422528 May 28 04:25 sys.log
-rw-r--r--. 1 root root  244010 May 28 05:26 sys.log.zip

解压缩zip文件

//解压文件
[root@localhost ~]# unzip sys.log.zip 
Archive:  sys.log.zip
replace sys.log? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
  inflating: sys.log 
//指定解压位置
[root@localhost ~]# unzip sys.log.zip -d /tmp
Archive:  sys.log.zip
  inflating: /tmp/sys.log   

**查看zip压缩包目录结构

[root@localhost ~]# unzip -l sys.log.zip 
Archive:  sys.log.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
  6422528  05-28-2018 04:25   sys.log
---------                     -------
  6422528                     1 file

六、tar打包

tar是一个打包工具而不是压缩工具。可以把目录和文件打包成一个文件。

语法: tar [zjxcvfpP] filename.tar file

打包

[root@localhost ~]# tar -cvf  demo.tar demo/
demo/
demo/1.iso.bz2
demo/1.txt
demo/1file
demo/2file
demo/file
demo/sys.log
demo/fd1/
demo/fd1/sys.log
demo/fd2/
demo/fd2/1.txt
[root@localhost ~]# ls
7lines-top.png.gz  anaconda-ks.cfg  demo  demo.tar  etc.zip  python  sh  sys.log  sys.log.zip
//打包时过滤文件1.txt,如需排队多个文件,则可以用多个exclude
[root@localhost ~]# tar -cvf demo.tar demo/ --exclude '1.txt' 
demo/
demo/fd1/
demo/fd1/sys.log
demo/fd2/
demo/1.iso.bz2
demo/1file
demo/2file
demo/file
demo/sys.log

解包

[root@localhost ~]# ll
total 35120
-rw-r--r--. 1 root root  7023391 May 28 04:22 7lines-top.png.gz
-rw-------. 1 root root     1313 May 26 05:56 anaconda-ks.cfg
drwxr-xr-x. 4 root root      103 May 28 05:39 demo
-rw-r--r--. 1 root root 12861440 May 28 05:44 demo.tar
-rw-r--r--. 1 root root  9402908 May 28 05:28 etc.zip
drwxr-xr-x. 2 root root        6 May 26 07:25 python
drwxr-xr-x. 2 root root        6 May 26 07:25 sh
-rw-r-----. 1 root root  6422528 May 28 04:25 sys.log
-rw-r--r--. 1 root root   244010 May 28 05:26 sys.log.zip
[root@localhost ~]# rm -rf demo
[root@localhost ~]# ll
total 35120
-rw-r--r--. 1 root root  7023391 May 28 04:22 7lines-top.png.gz
-rw-------. 1 root root     1313 May 26 05:56 anaconda-ks.cfg
-rw-r--r--. 1 root root 12861440 May 28 05:44 demo.tar
-rw-r--r--. 1 root root  9402908 May 28 05:28 etc.zip
drwxr-xr-x. 2 root root        6 May 26 07:25 python
drwxr-xr-x. 2 root root        6 May 26 07:25 sh
-rw-r-----. 1 root root  6422528 May 28 04:25 sys.log
-rw-r--r--. 1 root root   244010 May 28 05:26 sys.log.zip
[root@localhost ~]# tar -xvf demo.tar 
demo/
demo/fd1/
demo/fd1/sys.log
demo/fd2/
demo/fd2/1.txt
demo/1.iso.bz2
demo/1.txt
demo/1file
demo/2file
//解包到指定目录
[root@localhost ~]# tar -xvf demo.tar -C /tmp/
demo/
demo/fd1/
demo/fd1/sys.log
demo/fd2/
demo/fd2/1.txt
demo/1.iso.bz2
demo/1.txt
demo/1file
demo/2file
demo/file
demo/sys.log
[root@localhost ~]# ll /tmp/
total 13388
-rw-r--r--. 1 root root  220221 May 28 05:05 1.bz2
drwxr-xr-x. 4 root root     103 May 28 05:39 demo
-rwx------. 1 root root     663 May 26 05:56 ks-script-QSc1rl
-rw-r-----. 1 root root 6422528 May 28 04:25 sys.log
-rw-r--r--. 1 root root 6422528 May 28 04:53 sys.log1
-rw-r--r--. 1 root root  220221 May 28 05:14 sys.log.bzip2
-rw-r--r--. 1 root root  243872 May 28 05:14 sys.log.gz
-rw-r--r--. 1 root root  169588 May 28 05:15 sys.log.xz
-rw-------. 1 root root       0 May 26 05:47 yum.log

查看包中的文件

[root@localhost ~]# tar -tvf demo.tar 
drwxr-xr-x root/root         0 2018-05-28 05:39 demo/
drwxr-xr-x root/root         0 2018-05-28 05:39 demo/fd1/
-rw-r----- root/root   6422528 2018-05-28 05:39 demo/fd1/sys.log
drwxr-xr-x root/root         0 2018-05-28 05:39 demo/fd2/
-rw-r--r-- root/root      2534 2018-05-28 04:20 demo/fd2/1.txt
-rw-r--r-- root/root       113 2018-05-26 07:26 demo/1.iso.bz2
-rw-r--r-- root/root         8 2018-05-26 08:36 demo/1.txt
hrw-r--r-- root/root         0 2018-05-26 08:36 demo/1file link to demo/1.txt
lrwxrwxrwx root/root         0 2018-05-26 08:37 demo/2file -> 1.txt
-rw-r--r-- root/root        34 2018-05-26 09:11 demo/file
-rw-r--r-- root/root   6422528 2018-05-28 05:09 demo/sys.log

七、打包并压缩

tar也可以添加一些选项,来直接调用gzip和bzip2对打包文件进行压缩

-z 表示压缩成gzip压缩包

-j 表示压缩成bzip2压缩包

-J 表示压缩成xz压缩包

常用组合

-zcvf, z表示用gzip压缩,c表示建立,v表示可视化,f表示后跟文件名

[root@localhost ~]# tar -zcvf demo.tar.gz demo/
demo/
demo/fd1/
demo/fd1/sys.log
demo/fd2/
demo/fd2/1.txt
demo/1.iso.bz2
demo/1.txt
demo/1file
demo/2file
demo/file
demo/sys.log
//生成.tar.gz文件
[root@localhost ~]# ll
total 35600
-rw-r--r--. 1 root root  7023391 May 28 04:22 7lines-top.png.gz
-rw-------. 1 root root     1313 May 26 05:56 anaconda-ks.cfg
drwxr-xr-x. 4 root root      103 May 28 05:39 demo
-rw-r--r--. 1 root root 12861440 May 28 05:49 demo.tar
-rw-r--r--. 1 root root   491156 May 28 05:54 demo.tar.gz
-rw-r--r--. 1 root root  9402908 May 28 05:28 etc.zip
drwxr-xr-x. 2 root root        6 May 26 07:25 python
drwxr-xr-x. 2 root root        6 May 26 07:25 sh
-rw-r-----. 1 root root  6422528 May 28 04:25 sys.log
-rw-r--r--. 1 root root   244010 May 28 05:26 sys.log.zip

-jcvf, j表示用bzip2压缩,其他理zcvf里的含义相同

[root@localhost ~]# tar -jcvf demo.tar.bz2 demo/
demo/
demo/fd1/
demo/fd1/sys.log
demo/fd2/
demo/fd2/1.txt
demo/1.iso.bz2
demo/1.txt
demo/1file
demo/2file
demo/file
demo/sys.log
[root@localhost ~]# ll
total 36036
-rw-r--r--. 1 root root  7023391 May 28 04:22 7lines-top.png.gz
-rw-------. 1 root root     1313 May 26 05:56 anaconda-ks.cfg
drwxr-xr-x. 4 root root      103 May 28 05:39 demo
-rw-r--r--. 1 root root 12861440 May 28 05:49 demo.tar
-rw-r--r--. 1 root root   443855 May 28 05:56 demo.tar.bz2
-rw-r--r--. 1 root root   491156 May 28 05:54 demo.tar.gz
-rw-r--r--. 1 root root  9402908 May 28 05:28 etc.zip
drwxr-xr-x. 2 root root        6 May 26 07:25 python
drwxr-xr-x. 2 root root        6 May 26 07:25 sh
-rw-r-----. 1 root root  6422528 May 28 04:25 sys.log
-rw-r--r--. 1 root root   244010 May 28 05:26 sys.log.zip

-xvf, 解压缩包

[root@localhost ~]# rm -rf demo
//解gzip压缩的tar包
[root@localhost ~]# tar -xvf demo.tar.gz
demo/
demo/fd1/
demo/fd1/sys.log
demo/fd2/
demo/fd2/1.txt
demo/1.iso.bz2
demo/1.txt
demo/1file
demo/2file
demo/file
demo/sys.log
[root@localhost ~]# ll
total 36036
-rw-r--r--. 1 root root  7023391 May 28 04:22 7lines-top.png.gz
-rw-------. 1 root root     1313 May 26 05:56 anaconda-ks.cfg
drwxr-xr-x. 4 root root      103 May 28 05:39 demo
-rw-r--r--. 1 root root 12861440 May 28 05:49 demo.tar
-rw-r--r--. 1 root root   443855 May 28 05:56 demo.tar.bz2
-rw-r--r--. 1 root root   491156 May 28 05:54 demo.tar.gz
-rw-r--r--. 1 root root  9402908 May 28 05:28 etc.zip
drwxr-xr-x. 2 root root        6 May 26 07:25 python
drwxr-xr-x. 2 root root        6 May 26 07:25 sh
-rw-r-----. 1 root root  6422528 May 28 04:25 sys.log
-rw-r--r--. 1 root root   244010 May 28 05:26 sys.log.zip
//解bzip2压缩的tar包
[root@localhost ~]# rm -rf demo
[root@localhost ~]# tar -xvf demo.tar.bz2 
demo/
demo/fd1/
demo/fd1/sys.log
demo/fd2/
demo/fd2/1.txt
demo/1.iso.bz2
demo/1.txt
demo/1file
demo/2file
demo/file
demo/sys.log
[root@localhost ~]# ll
total 36036
-rw-r--r--. 1 root root  7023391 May 28 04:22 7lines-top.png.gz
-rw-------. 1 root root     1313 May 26 05:56 anaconda-ks.cfg
drwxr-xr-x. 4 root root      103 May 28 05:39 demo
-rw-r--r--. 1 root root 12861440 May 28 05:49 demo.tar
-rw-r--r--. 1 root root   443855 May 28 05:56 demo.tar.bz2
-rw-r--r--. 1 root root   491156 May 28 05:54 demo.tar.gz
-rw-r--r--. 1 root root  9402908 May 28 05:28 etc.zip
drwxr-xr-x. 2 root root        6 May 26 07:25 python
drwxr-xr-x. 2 root root        6 May 26 07:25 sh
-rw-r-----. 1 root root  6422528 May 28 04:25 sys.log
-rw-r--r--. 1 root root   244010 May 28 05:26 sys.log.zip

-tvf查看压缩的tar包

//查看gzip压缩的tar包
[root@localhost ~]# tar -tvf demo.tar.gz 
drwxr-xr-x root/root         0 2018-05-28 05:39 demo/
drwxr-xr-x root/root         0 2018-05-28 05:39 demo/fd1/
-rw-r----- root/root   6422528 2018-05-28 05:39 demo/fd1/sys.log
drwxr-xr-x root/root         0 2018-05-28 05:39 demo/fd2/
-rw-r--r-- root/root      2534 2018-05-28 04:20 demo/fd2/1.txt
-rw-r--r-- root/root       113 2018-05-26 07:26 demo/1.iso.bz2
-rw-r--r-- root/root         8 2018-05-26 08:36 demo/1.txt
hrw-r--r-- root/root         0 2018-05-26 08:36 demo/1file link to demo/1.txt
lrwxrwxrwx root/root         0 2018-05-26 08:37 demo/2file -> 1.txt
-rw-r--r-- root/root        34 2018-05-26 09:11 demo/file
-rw-r--r-- root/root   6422528 2018-05-28 05:09 demo/sys.log
//查看bzip2压缩的tar包
[root@localhost ~]# tar -tvf demo.tar.bz2 
drwxr-xr-x root/root         0 2018-05-28 05:39 demo/
drwxr-xr-x root/root         0 2018-05-28 05:39 demo/fd1/
-rw-r----- root/root   6422528 2018-05-28 05:39 demo/fd1/sys.log
drwxr-xr-x root/root         0 2018-05-28 05:39 demo/fd2/
-rw-r--r-- root/root      2534 2018-05-28 04:20 demo/fd2/1.txt
-rw-r--r-- root/root       113 2018-05-26 07:26 demo/1.iso.bz2
-rw-r--r-- root/root         8 2018-05-26 08:36 demo/1.txt
hrw-r--r-- root/root         0 2018-05-26 08:36 demo/1file link to demo/1.txt
lrwxrwxrwx root/root         0 2018-05-26 08:37 demo/2file -> 1.txt
-rw-r--r-- root/root        34 2018-05-26 09:11 demo/file
-rw-r--r-- root/root   6422528 2018-05-28 05:09 demo/sys.log

扩展链接:http://ask.apelearn.com/question/5435

原文地址:https://www.cnblogs.com/minn/p/9098686.html