linux修改文件所属的用户组以及用户

背景:
将文件夹从A用户(huangxf)目录复制B用户(zhenglf)目录,其中B没有sudo权限。
将A的Downloads文件夹下的所有文件,复制到B的Documents文件夹下,
此时在Documents文件夹下多了一个Downloads文件夹


可使用以下命令,将sourceDir文件夹拷贝到destDir文件夹下:
cp sourceDir/ destDir/ -rf


在A用户的终端执行
sudo  cp  -R  /home/huangxf/Downloads/   /home/zhenglf/Documents/Downloads/


修改所有者
sudo  chown  -R  zhenglf  /home/zhenglf/Documents/Downloads/


修改用户组
sudo  chgrp  -R  zhenglf  /home/zhenglf/Documents/Downloads/


此时B用户是复制过来的文件拥有者,在B用户的终端可以对此文件修改权限
修改文件权限
chmod  -R  777  /home/zhenglf/Documents/Downloads/

猜你喜欢

转载自blog.csdn.net/zlf19910726/article/details/80968332
今日推荐