[英]How to create a soft link without path of the parent directories in linux?
We are creating a soft link using below command. 我们正在使用以下命令创建一个软链接。
ln -sf /home/root/Test "/home/root/TestSoftLink"
So our TestSoftLink will be pointing to /home/root/Test 因此,我们的TestSoftLink将指向/ home / root / Test
TestSoftLink -> /home/root/Test
Our requirement : When we do ll
under /home/root/
TestSoftLink should point to Test (Without parent directories) like below 我们的要求:在
/home/root/
下执行ll
,TestSoftLink应该指向Test(不带父目录),如下所示
TestSoftLink -> Test
Note : both Test and TestSoftLink should be present under /home/root/
注意:Test和TestSoftLink都应位于
/home/root/
Is it possible? 可能吗?
The ln -s
command simply takes the string of the first argument, and writes it into the symbolic link. ln -s
命令仅采用第一个参数的字符串,并将其写入符号链接。 As such, it is perfectly valid to do this: 因此,这样做是完全有效的:
ln -sf Test "/home/root/TestSoftLink"
There is no need to do a cd
. 无需执行
cd
。
正如@cuihtlauac提到的,我们使用下面的命令,它起作用了!
cd /home/root; ln -sf Test TestSoftLink
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.