linux p 参数,tar的-p参数解决方案

当前位置:我的异常网» Linux/Unix » tar的-p参数解决方案

tar的-p参数解决方案

www.myexceptions.net  网友分享于:2013-01-05  浏览:7次

tar的-p参数

tar的-p参数到底是什么含义:

在man中,解释如下:extract all protection information 提取所有受保护的信息。

问题1:那么,什么叫受保护的信息呢?

在info中,解释如下:

`--preserve-permissions'

`--same-permissions'

`-p'

When `tar' is extracting an archive, it normally subtracts the

users' umask from the permissions specified in the archive and uses

that number as the permissions to create the destination file.

Specifying this option instructs `tar' that it should use the

permissions directly from the archive.  *Note Writing::.

也就是说,加了-p之后,tar进行解压后,生成的文件的权限,是直接取自tar包里面文件的权限,那么不加-p参数,将还要再减去umask的值

但是我测试了下,结果视乎不是这样的:

==========各属性权限如下:

root@DaLinux liuda]# ll

total 76

-rw-r--r-- 1 root root    3 Oct 11 02:44 1

-rwxrwxrwx 1 root root   11 Oct 12 02:15 10

-rw-r--r-- 1 root root    3 Oct 12 12:45 11

-rw-r--r-- 1 root root    5 Oct 12 12:53 12

-rw-r--r-- 1 root root    2 Oct 11 02:45 2

-rw-r--r-- 1 root root    2 Oct 11 02:45 3

-rw-r--r-- 1 root root    2 Oct 11 02:45 4

-rw-r--r-- 1 root root    2 Oct 11 02:45 5

-rwxrwxrwx 1 root root    2 Oct 11 02:51 6

-rwxrwxrwx 1 root root    2 Oct 12 12:54 7

-rwxrwxrwx 1 root root    2 Oct 12 12:48 8

-rwxrwxrwx 1 root root 4635 Oct 11 03:23 9

drwxr-xr-x 2 root root 4096 Oct 12 02:18 liuda

-rw-r--r-- 1 root root 4617 Oct 12 12:06 man.config

-rw-r--r-- 1 root root 2049 Oct 12 12:06 man.config.bz2

-rw-r--r-- 1 root root 2049 Oct 12 12:06 man.config.bz2-3

-rw-r--r-- 1 root root   79 Sep 19 02:51 sed

==========这是进行压缩:

root@DaLinux liuda]# tar -jcv -f ../ccc/test.tar.bz2 .

./

./6

./7

./sed

./11

./9

./liuda/

./liuda/77

./3

./2

./4

./1

./man.config.bz2

./8

./5

./man.config

./man.config.bz2-3

./12

./10

=================这是进行解压

[root@DaLinux ccc]# tar -xv -f test.tar.bz2 -C ccc/

./

./6

./7

./sed

./11

./9

./liuda/

./liuda/77

./3

./2

./4

./1

./man.config.bz2

./8

./5

./man.config

./man.config.bz2-3

./12

./10

===========这是查看解压后生成的文件的权限

[root@DaLinux ccc]# ll

total 76

-rw-r--r-- 1 root root    3 Oct 11 02:44 1

-rwxrwxrwx 1 root root   11 Oct 12 02:15 10

-rw-r--r-- 1 root root    3 Oct 12 12:45 11

-rw-r--r-- 1 root root    5 Oct 12 12:53 12

文章评论

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值