VGH
VGH

Reputation: 425

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?

Upvotes: 5

Views: 3560

Answers (2)

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.

Upvotes: 4

VGH
VGH

Reputation: 425

As @cuihtlauac mentioned , We used below command and it worked !

cd /home/root; ln -sf Test TestSoftLink

Upvotes: 2

Related Questions