为什么 bash 无法在 /usr/local/bin 中创建符号链接?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47189213/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 16:35:10  来源:igfitidea点击:

Why is bash failing to create a symbolic link in /usr/local/bin?

bashterminalsublimetext3

提问by Kevin Mangal

Attempting to create a symbolic link for the subl command so that I can open flies in Sublime Test 3 from the terminal. However, it fails to find the /usr/local/bin directory, even though it is in my path.

尝试为 subl 命令创建符号链接,以便我可以从终端在 Sublime Test 3 中打开苍蝇。但是,它无法找到 /usr/local/bin 目录,即使它在我的路径中。

 $ ln -s /D/ProgramsD/SublimeText3/subl /usr/local/bin/subl
 ln: failed to create symbolic link '/usr/local/bin/subl': No such file or directory

回答by janos

ln: failed to create symbolic link '/usr/local/bin/subl': No such file or directory

ln: 未能创建符号链接 '/usr/local/bin/subl': 没有那个文件或目录

This error can happen when one of the parent directories of /usr/local/bin/subldon't exist.

当 的父目录之一/usr/local/bin/subl不存在时,可能会发生此错误。

Create them with:

创建它们:

mkdir -p /usr/local/bin

However, it fails to find the /usr/local/bindirectory, even though it is in my path.

但是,它无法找到该/usr/local/bin目录,即使它在我的路径中。

As the output of ls -ld /usr/local/binreveals, indeed there is no such directory. The fact that the directory is on your PATHis irrelevant, because being on the PATHdoesn't imply that a directory actually exists. In your example it doesn't exist, you need to create it.

正如输出ls -ld /usr/local/bin显示的那样,确实没有这样的目录。目录在您的PATH位置这一事实无关紧要,因为在 上PATH并不意味着目录确实存在。在您的示例中它不存在,您需要创建它。