LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   ln -s Help (quick and simple) (https://www.linuxquestions.org/questions/linux-software-2/ln-s-help-quick-and-simple-533057/)

timrs 02-27-2007 04:35 PM

ln -s Help (quick and simple)
 
Here is a quick and simple problem.
If I type
Code:

ln -s kaid kaid2
The command './kaid2' works fine. If I type
Code:

ln -s kaid /usr/bin/kaid
I end up with an error, the command 'kaid' now says command not found, and
Code:

cannot access `/usr/bin/kaid': Too many levels of symbolic links

BrianK 02-27-2007 07:16 PM

Quote:

Originally Posted by timrs
Here is a quick and simple problem.
If I type
Code:

ln -s kaid kaid2
The command './kaid2' works fine. If I type
Code:

ln -s kaid /usr/bin/kaid
I end up with an error, the command 'kaid' now says command not found, and
Code:

cannot access `/usr/bin/kaid': Too many levels of symbolic links

it's

ln -s <target> <symbol>

not

ln -s <symbol> <target>

In other words, in your second example, you make a symbolic link called /usr/bin/kaid that links to something called "kaid" which would likely be in ./ and not really be anything. You should do:

ln -s /usr/bin/kaid kaid

timrs 02-27-2007 08:15 PM

Nope, you're backwards.

pixellany 02-27-2007 08:24 PM

From man ln:
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)

You make a link to a target---the target name always comes first---except #4 (which I do not understand)

In OPs 1st example, the order was target, link and the link worked

I think the problem has to do with using full pathnames in certain situations, but lets confirm with OP---where in fact is the target file? Is it possible that the first example worked because kaid2 is really the target?

timrs 02-27-2007 09:15 PM

Could you check if your right the next time you post? Its not that hard. I bet you $999999999999 you have this program (ln) too and are capable of checking yourself.

pixellany 02-28-2007 12:59 AM

Quote:

Originally Posted by timrs
Could you check if your right the next time you post? Its not that hard. I bet you $999999999999 you have this program (ln) too and are capable of checking yourself.

timrs;
Who is this addressed to? I suddenly find that I don't know what this thread is about. You posed a question--- Do you now have the answer?

If your post is saying that someone made a mistake, perhaps you should say what the mistake was......

timrs 02-28-2007 06:26 AM

No, sorry, but the command i have is correct... it works in the current directory, but when the link is in /usr/bin it doesn't work

pixellany 02-28-2007 07:59 AM

As I said in my other post, it has to do with specifying full path names. I just tried a few experiments.
If I link OUT of a folder, I needed to specify the full path name.
When in /opt:
ln -s vpnclient /home/mherring/Desktop does not work
whereas
ln -s /opt/vpnclient /home/mherring/Desktop DOES work

But if I am in /home/mherring/Desktop, I can do:
ln -s /opt/vpnclient vpnclient, and it works

And that's the truth........

timrs 02-28-2007 03:04 PM

Thankyou, this is strange though -- did the developers do this on purpose?

pixellany 02-28-2007 03:20 PM

Quote:

Originally Posted by timrs
Thankyou, this is strange though -- did the developers do this on purpose?

As opposed to what? accident? mistake?

No, I think there is probably a rational reason for it to be that way--but I have never seen it...

The really easy way to stay out of trouble is to always link IN, using the default link name:
ln -s /path/path/target
Automatically creates the link in the current directory with the name of "target"

timrs 03-03-2007 03:47 PM

I think its because when ln -s 1 /dir/2 is made, the file /dir/2 is literally linked to 1, and there is no 1 in the directory 2 is in -- thats the best I can explain it


All times are GMT -5. The time now is 08:34 PM.