2013-02-17 126 views
2

复制软件包时,我有充分的权限(777)(includeing子目录)权限更改在OSX

的包目录,每当我用cp将其复制到另一个目录-r我看到它失去了它的一些权限。

原因是什么?如何在保持其权限不变的情况下移动此软件包?

我有一个狮子版本。

谢谢

回答

3

使用-p标志:

cp -Rp whatever whereever 

cp手册页:

Cause cp to preserve the following attributes of each source file 
in the copy: modification time, access time, file flags, file mode, 
user ID, and group ID, as allowed by permissions. Access Control 
Lists (ACLs) and Extended Attributes (EAs), including resource 
forks, will also be preserved. 

If the user ID and group ID cannot be preserved, no error message 
is displayed and the exit value is not altered. 
If the source file has its set-user-ID bit on and the user ID can- 
not be preserved, the set-user-ID bit is not preserved in the 
copy's permissions. If the source file has its set-group-ID bit on 
and the group ID cannot be preserved, the set-group-ID bit is not 
preserved in the copy's permissions. If the source file has both 
its set-user-ID and set-group-ID bits on, and either the user ID or 
group ID cannot be preserved, neither the set-user-ID nor set- 
group-ID bits are preserved in the copy's permissions. 
+2

@kambi:还要注意使用'-R'而比@ trojanfoe的答案中的'-r'。 '-r'可以被打破但保留向后兼容性。看到手册页的底部:“cp实用程序的历史版本有一个-r选项,该实现支持该选项;但是强烈建议不要使用它,因为它不能正确复制特殊文件,符号链接或fifo。 “ – 2013-02-17 18:47:19

+1

其实最简单的选择是'-a',它和'-pPR'相同。 – trojanfoe 2013-02-17 19:00:37

+1

@KenThomases谢谢,我不知道 – kambi 2013-02-19 07:56:40