2013-02-17 133 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