linux终端命令复制文件,如何通过终端命令将所有文件和目录复制到其他用户

两个用户之间的命令只能由root用户执行。su root

(or)

sudo su

可以通过以下命令在两个用户之间复制文件。cp /home/user1/location_of_the_files /home/user2/location_to_paste_file

可以通过以下命令在两个用户之间移动文件。mv /home/user1/location_of_the_files /home/user2/location_to_paste_file

另外一种方法:# As user1, mv or cp to your home dir (alternative /tmp):

mv /home/user1/path/to/location_of_the_files /home/user1/

# Give user2 access to read files and read and access directories

setfacl -R -m u:user2:rX /home/user1/location_of_the_files

# Login as user2

su user2

cp -r /home/user1/location_of_the_files ~/

# Back to user1:

# delete the directory if you wanted it moved

# or move it back to the original location and remove the facl using:

setfacl -Rbn /home/user1/location_of_the_files

如果安装了SSH服务器并启用了SSH,则更容易:# As user2

scp -r user1@localhost:/home/user1/path/to/location_of_the_files/ ~/

相关文章

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值