在Ubuntu中创建目录的符号链接 [英] Create a symbolic link of directory in Ubuntu
问题描述
以下是我用于创建目录符号链接的代码:
Below is my code for creating a symlink of a directory:
sudo ln -s /usr/local/nginx/conf/ /etc/nginx
我已经创建了目录/etc/nginx
.我只希望源目录(/usr/local/nginx/conf/
)的内容在目标目录(/etc/nginx
)的内容中.但是,当我执行代码时,/etc/nginx
包含一个名为conf
的目录,而不是conf
的内容.该目录包含我想要的内容,但是位置错误.
I already created the directory /etc/nginx
. I just want the contents of the source directory (/usr/local/nginx/conf/
) to be in the contents of the target directory (/etc/nginx
). But when I execute the code, /etc/nginx
contains a directory called conf
, instead of the contents of conf
. That directory contains the contents I want, but in the wrong location.
为什么将目录放置在目标文件夹中,而不是仅将目录内容放置在目标文件夹中?
Why did it put a directory in the target folder, instead of just putting the contents of the directory in the target folder?
推荐答案
如果第二个arg是目录,则这是ln
的行为.它将指向其内第一个arg 的链接.如果要/etc/nginx
作为符号链接,则应首先删除该目录并运行相同的命令.
This is the behavior of ln
if the second arg is a directory. It places a link to the first arg inside it. If you want /etc/nginx
to be the symlink, you should remove that directory first and run that same command.
这篇关于在Ubuntu中创建目录的符号链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!