mac命令行复制文件权限问题


mac osx系统 我在一个目录下执行了下面的操作


 cp -R backend/ api

ls -al
drwxr-xr-x@  9 root    admin    306  7 15 09:46 api
drwxr-xr-x@ 10 xinyue  admin    340  7 15 10:40 backend

复制之后发现 他是属于root的,如何让复制后也和上面的backend一样属于xinyue

mac bash

狼と香辛料 9 years, 11 months ago

 cp -Rp backend/ api

# man cp
-p    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.

无节操D红白姬 answered 9 years, 11 months ago

sudo chown xinyue:admin api

刺猬丶顶上天 answered 9 years, 11 months ago

切换成那个用户,或者拷贝之后 chown 更换拥有人

三茎受 answered 9 years, 11 months ago

不需要切换用户,sudo就可以。


 sudo chown xinyue:admin api

阿姆罗 answered 9 years, 11 months ago

Your Answer