您好,我在 CentOS 服务器上,我有一个名为 'theowner'
的用户,因此他的文件夹位于 /home/theowner
另一方面,我在 /home/myprojects/src
下有 2 个文件夹,f1 和 f2,我只想这些文件夹出现在 /home/theowner
下,但我不想移动该文件夹
我想要的是将这 2 个文件夹链接到 /home/theowner
。它适用于 c9 工作区,我只想允许所有者在登录时直接访问该文件夹。谢谢!
最佳答案
@Lubomir已经给出了符号链接(symbolic link)解决方案。
但是,他的解决方案将要求 theowner
至少对 /home/myprojects/src/f1
和 /home/myprojects/src/f2
的所有父目录拥有读取执行
权限。
在大多数情况下,您不希望theowner
看到/home/myprojects/src/f1
和/home/myprojects/src/f2
之外的任何内容。
绑定(bind)安装来救援。
作为所有者
创建以下目录。
$ mkdir f1 f2
作为root
,将源目录挂载到目标目录。
# mount -o bind /home/myprojects/src/f1 /home/theowner/f1
# mount -o bind /home/myprojects/src/f2 /home/theowner/f2
如果您希望它在重新启动后仍然存在,请在/etc/fstab 中添加 2 个条目
/home/myprojects/src/f1 /home/theowner/f1 auto auto,bind 0 0
/home/myprojects/src/f2 /home/theowner/f2 auto auto,bind 0 0
使用此解决方案,theowner
不需要访问 /home/myprojects/src/f1
和 /home/myprojects/src/f2
的父目录。
关于linux - CentOS 7 中的链接目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43748289/