Linux 如何创建指向目录的链接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9587445/
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
How to create a link to a directory
提问by read Read
How to create a link xxx
to /home/jake/doc/test/2000/something/
?
如何创建一个链接xxx
到/home/jake/doc/test/2000/something/
?
Assume the xxx
is created under /home/jake
and you're currently in /home/jake
. When you do cd xxx
, you directly go to /home/jake/doc/test/2000/something/
.
假设xxx
是在 下创建的/home/jake
并且您当前在/home/jake
. 当你这样做时cd xxx
,你直接去/home/jake/doc/test/2000/something/
。
采纳答案by theglauber
Symbolic or soft link (files or directories, more flexible and self documenting)
符号或软链接(文件或目录,更灵活和自我记录)
# Source Link
ln -s /home/jake/doc/test/2000/something /home/jake/xxx
Hard link (files only, less flexible and not self documenting)
硬链接(仅限文件,不太灵活且不自记录)
# Source Link
ln /home/jake/doc/test/2000/something /home/jake/xxx
More information: man ln
更多信息:man ln
/home/jake/xxx
is like a new directory. To avoiod "is not a directory: No such file or directory"error, as @trlkly comment, use relative path in the target, that is, using the example:
/home/jake/xxx
就像一个新目录。为避免“is not a directory: No such file or directory”错误,作为@trlkly 注释,在目标中使用相对路径,即使用示例:
cd /home/jake/
ln -s /home/jake/doc/test/2000/something xxx
cd /home/jake/
ln -s /home/jake/doc/test/2000/something xxx
回答by WiseTechi
you should use :
你应该使用:
ln -s /home/jake/doc/test/2000/something xxx