我在nfs挂载上有一个目录,该目录在服务器上位于 /home/myname/.rubies
根无法访问此目录:
[mitchell.usher@server ~]$ stat /home/mitchell.usher/.rubies
File: `/home/mitchell.usher/.rubies'
Size: 4096 Blocks: 8 IO Block: 32768 directory
Device: 15h/21d Inode: 245910 Links: 3
Access: (0755/drwxr-xr-x) Uid: ( 970/mitchell.usher) Gid: ( 100/ users)
Access: 2016-08-22 15:06:15.000000000 +0000
Modify: 2016-08-22 14:55:00.000000000 +0000
Change: 2016-08-22 14:55:00.000000000 +0000
[mitchell.usher@server ~]$ sudo !!
sudo stat /home/mitchell.usher/.rubies
stat: cannot stat `/home/mitchell.usher/.rubies': Permission denied
我正在尝试从该目录中复制某些内容/opt
,只有root可以访问该目录:
[mitchell.usher@server ~]$ cp .rubies/ruby-2.1.3/ -r /opt
cp: cannot create directory `/opt/ruby-2.1.3': Permission denied
[mitchell.usher@server ~]$ sudo !!
sudo cp .rubies/ruby-2.1.3/ -r /opt
cp: cannot stat `.rubies/ruby-2.1.3/': Permission denied
显然,我可以执行以下操作(这是我目前所做的):
[mitchell.usher@server ~]$ cp -r .rubies/ruby-2.1.3/ /tmp/
[mitchell.usher@server ~]$ sudo cp -r /tmp/ruby-2.1.3/ /opt/
有什么方法可以执行此操作,而无需将其复制为中间步骤或更改权限?
如问题中所述,@ MelBurslan就是我所做的。但是,假设它是一个50 GB的文件,无法容纳文件系统上的其他任何位置,那么我将无法做到
—
Mitch
cp <file> /tmp/tmpfile
cp -Rp /home/mitchell.usher/.rubies /tmp/templocation; sudo mv /tmp/templocation/ruby-2.1.3 /opt
这行不通吗?如果没有,为什么?