在 Ubuntu 中创建目录的符号链接 [英] Create a symbolic link of directory in Ubuntu

查看:84
本文介绍了在 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?

推荐答案

如果第二个参数是目录,这是 ln 的行为.它在里面放置了一个指向第一个参数的链接.如果您希望 /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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆