简体   繁体   English

创建指向多个目录中心的符号链接

[英]create a symbolic link to multiple directory centos

I have currently created a symbolic link in var/www/html/lenova/ . 我目前在var / www / html / lenova /中创建了一个符号链接。 It is currently linked to "assets" when I execute 当我执行时,它当前链接到“资产”

   ll 

this is what gets displayed 这就是显示

    assets -> ../../../assets

I need to create another link to assets in a different folder var/www/html/dell. 我需要在另一个文件夹var / www / html / dell中创建指向资产的另一个链接。

so end results would be 所以最终结果是

   assets-> ../../../assets

when I execute 当我执行

  ln -s assets ../../../assets

it displays 它显示

 ln: creating symbolic link `../../../assets/assets` to `assets`: File exists

How can I achieve the second symbolic link as-well? 我如何也可以实现第二个符号链接? This folder needs to be shared by multiple projects 此文件夹需要由多个项目共享

As Biffen stated, the arguments to ln are target first, then the link name. 正如Biffen所说, ln的参数首先是目标,然后是链接名称。 man ls shows: man ls显示:

SYNOPSIS
       ln [OPTION]... [-T] TARGET LINK_NAME   (1st form)
       ln [OPTION]... TARGET                  (2nd form)
       ln [OPTION]... TARGET... DIRECTORY     (3rd form)
       ln [OPTION]... -t DIRECTORY TARGET...  (4th form)

Assuming that 'var/www/html/dell' (the directory where you want the link) is the current working directory, you don't even need to specify the link name as you want it to be the same as the target: ln -s ../../../assets Although, personally I am in the habit of specifying the destination directory: ln -s ../../../assets . 假设“ var / www / html / dell”(您想要链接的目录)是当前的工作目录,那么您甚至不需要指定链接名称即可,因为它希望与目标名称相同: ln -s ../../../assets虽然,我个人习惯指定目标目录: ln -s ../../../assets . If you really wanted to have the arguments in the order which you were using, you could use the -t option: ln -s -t . ../../../assets 如果您确实想按使用的顺序排列参数,则可以使用-t选项: ln -s -t . ../../../assets ln -s -t . ../../../assets However, in that case you are specifying a directory, not the name of the link. ln -s -t . ../../../assets但是,在这种情况下,您指定的是目录,而不是链接的名称。 To force the specifying the name of the link instead of a directory, use the -T option. 要强制指定链接的名称而不是目录,请使用-T选项。

If you are not sure how a command works both the man , and info commands are available to provide information. 如果不确定命令的工作方式,那么maninfo命令都可以提供信息。 It is not uncommon to use either an additional command window to show the man/help information while you are working, or to use job control to have the information available in the same command instance. 在工作时使用附加的命令窗口来显示人员/帮助信息,或者使用作业控制在同一命令实例中使信息可用,这种情况并不罕见。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM