简体   繁体   中英

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

Our requirement : When we do ll under /home/root/ TestSoftLink should point to Test (Without parent directories) like below

TestSoftLink -> Test

Note : both Test and TestSoftLink should be present under /home/root/

Is it possible?

The ln -s command simply takes the string of the first argument, and writes it into the symbolic link. As such, it is perfectly valid to do this:

ln -sf Test "/home/root/TestSoftLink"

There is no need to do a cd .

正如@cuihtlauac提到的,我们使用下面的命令,它起作用了!

cd /home/root; ln -sf Test TestSoftLink

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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