soft links across directoruies - Mandriva

This is a discussion on soft links across directoruies - Mandriva ; I always do this to myself in the middle of the night. A five second job turns into an hour of mystery, man pages, googling and banging head on keyboard. All I wished to do was to make a link ...

+ Reply to Thread
Results 1 to 10 of 10

Thread: soft links across directoruies

  1. soft links across directoruies

    I always do this to myself in the middle of the night. A five second job turns
    into an hour of mystery, man pages, googling and banging head on keyboard.

    All I wished to do was to make a link from $HOME/myfile to the Desktop.

    Simple

    [nykysle@unimatrix ~]$ ln -s myfile Desktop/

    Well it didn't quite work. Actually I get a broken link on the desktop pointing
    to itself.

    [nykysle@unimatrix Desktop]$ ll myfile
    lrwxrwxrwx 1 nykysle nykysle 6 Aug 19 00:23 myfile -> myfile

    flashing because it's broken, of course.

    After a lot of trial I found that absolute path names work fine

    ln -s /home/nykysle/myfile /home/nykysle/Desktop/

    Now I have a link.
    I could have use the file manager but I got a bit bloody minded after a while.

    I failed when testing other directory links too, unless full paths were used.
    So the Desktop isn't special.

    Are absolute paths really necessary when crossing directories?

    --
    faeychild

  2. Re: soft links across directoruies

    On Mon, 18 Aug 2008 11:15:10 -0400, faeychild wrote:

    > All I wished to do was to make a link from $HOME/myfile to the Desktop.
    > [nykysle@unimatrix ~]$ ln -s myfile Desktop/


    The paramaters are backwards. The existing item (target), that you are making
    a link to, goes first. If the target is in the same directory, or you want
    to use a different name, or create the link in a directory other then the
    current directory, then the second parameter says what name the symlink
    will have, in the directory where the symlink is being created.

    ln -s Desktop myfile

    If the target is in another directory, and you do not specify the second
    paramater, the symlink will be created in the current directory, with the
    same name as the target.

    If you include the trailing slash on a directory name, the symlink will have
    to slashes in it. Doesn't hurt anything, but I prefer not to.

    Regards, Dave Hodgins

    --
    Change nomail.afraid.org to ody.ca to reply by email.
    (nomail.afraid.org has been set up specifically for
    use in usenet. Feel free to use it yourself.)

  3. Re: soft links across directoruies

    David W. Hodgins wrote:

    > On Mon, 18 Aug 2008 11:15:10 -0400, faeychild wrote:
    >
    >> All I wished to do was to make a link from $HOME/myfile to the Desktop.
    >> [nykysle@unimatrix ~]$ ln -s myfile Desktop/

    >
    > The paramaters are backwards. The existing item (target), that you are
    > making
    > a link to, goes first.


    Yes correct. I have a file in the home directory that I want to access from
    the Desktop

    > If the target is in the same directory, or you want
    > to use a different name, or create the link in a directory other then the
    > current directory, then the second parameter says what name the symlink
    > will have, in the directory where the symlink is being created.
    >
    > ln -s Desktop myfile


    If I try this

    [nykysle@unimatrix ~]$ ln -s Desktop myfile
    ln: creating symbolic link `myfile' to `Desktop': File exists.

    Well yes it does exist in the home directory.

    [nykysle@unimatrix ~]$ ls -l /home/nykysle/myfile
    -rw-r--r-- 1 nykysle nykysle 16 Aug 19 00:22 /home/nykysle/myfile

    but there is no link to it on the Desktop

    [nykysle@unimatrix ~]$ ls -l Desktop/myfile
    ls: Desktop/myfile: No such file or directory

    And I want a link to it placed on /home/nykysle/Desktop.

    The only way it works is with this

    ln -s /home/nykysle/myfile /home/nykysle/Desktop/myfile

    Which is stupidly long winded. It must be possible and shorter to use relative
    addressing.
    It is purely academic now but I an annoyed that I can't find the combination to
    make it work

    --
    faeychild

  4. Re: soft links across directoruies

    faeychild wrote:

    > David W. Hodgins wrote:
    >
    >> On Mon, 18 Aug 2008 11:15:10 -0400, faeychild
    >> wrote:
    >>
    >>> All I wished to do was to make a link from $HOME/myfile to the Desktop.
    >>> [nykysle@unimatrix ~]$ ln -s myfile Desktop/

    >>
    >> The paramaters are backwards. The existing item (target), that you are
    >> making
    >> a link to, goes first.

    >
    > Yes correct. I have a file in the home directory that I want to access
    > from the Desktop
    >
    >> If the target is in the same directory, or you want
    >> to use a different name, or create the link in a directory other then the
    >> current directory, then the second parameter says what name the symlink
    >> will have, in the directory where the symlink is being created.
    >>
    >> ln -s Desktop myfile

    >
    > If I try this
    >
    > [nykysle@unimatrix ~]$ ln -s Desktop myfile
    > ln: creating symbolic link `myfile' to `Desktop': File exists.
    >
    > Well yes it does exist in the home directory.
    >
    > [nykysle@unimatrix ~]$ ls -l /home/nykysle/myfile
    > -rw-r--r-- 1 nykysle nykysle 16 Aug 19 00:22 /home/nykysle/myfile
    >
    > but there is no link to it on the Desktop
    >
    > [nykysle@unimatrix ~]$ ls -l Desktop/myfile
    > ls: Desktop/myfile: No such file or directory
    >
    > And I want a link to it placed on /home/nykysle/Desktop.
    >
    > The only way it works is with this
    >
    > ln -s /home/nykysle/myfile /home/nykysle/Desktop/myfile
    >
    > Which is stupidly long winded. It must be possible and shorter to use
    > relative addressing.
    > It is purely academic now but I an annoyed that I can't find the
    > combination to make it work
    >


    cd ~
    ln -s myfile Desktop/myfile

    Jim

  5. Re: soft links across directoruies

    faeychild wrote:

    > David W. Hodgins wrote:
    >
    >> On Mon, 18 Aug 2008 11:15:10 -0400, faeychild
    >> wrote:
    >>
    >>> All I wished to do was to make a link from $HOME/myfile to the Desktop.
    >>> [nykysle@unimatrix ~]$ ln -s myfile Desktop/

    >>
    >> The paramaters are backwards. The existing item (target), that you are
    >> making
    >> a link to, goes first.

    >
    > Yes correct. I have a file in the home directory that I want to access
    > from the Desktop
    >
    >> If the target is in the same directory, or you want
    >> to use a different name, or create the link in a directory other then the
    >> current directory, then the second parameter says what name the symlink
    >> will have, in the directory where the symlink is being created.
    >>
    >> ln -s Desktop myfile

    >
    > If I try this
    >
    > [nykysle@unimatrix ~]$ ln -s Desktop myfile
    > ln: creating symbolic link `myfile' to `Desktop': File exists.
    >
    > Well yes it does exist in the home directory.
    >
    > [nykysle@unimatrix ~]$ ls -l /home/nykysle/myfile
    > -rw-r--r-- 1 nykysle nykysle 16 Aug 19 00:22 /home/nykysle/myfile
    >
    > but there is no link to it on the Desktop
    >
    > [nykysle@unimatrix ~]$ ls -l Desktop/myfile
    > ls: Desktop/myfile: No such file or directory
    >
    > And I want a link to it placed on /home/nykysle/Desktop.
    >
    > The only way it works is with this
    >
    > ln -s /home/nykysle/myfile /home/nykysle/Desktop/myfile
    >
    > Which is stupidly long winded. It must be possible and shorter to use
    > relative addressing.
    > It is purely academic now but I an annoyed that I can't find the
    > combination to make it work
    >


    Please ignore my earlier post. My suggestion doesn't work. I must have had
    a "brain-fart".

    Jim

  6. Re: soft links across directoruies

    faeychild wrote:

    > David W. Hodgins wrote:
    >
    >> On Mon, 18 Aug 2008 11:15:10 -0400, faeychild
    >> wrote:
    >>
    >>> All I wished to do was to make a link from $HOME/myfile to the Desktop.
    >>> [nykysle@unimatrix ~]$ ln -s myfile Desktop/

    >>
    >> The paramaters are backwards. The existing item (target), that you are
    >> making
    >> a link to, goes first.

    >
    > Yes correct. I have a file in the home directory that I want to access
    > from the Desktop
    >
    >> If the target is in the same directory, or you want
    >> to use a different name, or create the link in a directory other then the
    >> current directory, then the second parameter says what name the symlink
    >> will have, in the directory where the symlink is being created.
    >>
    >> ln -s Desktop myfile

    >
    > If I try this
    >
    > [nykysle@unimatrix ~]$ ln -s Desktop myfile
    > ln: creating symbolic link `myfile' to `Desktop': File exists.
    >
    > Well yes it does exist in the home directory.
    >
    > [nykysle@unimatrix ~]$ ls -l /home/nykysle/myfile
    > -rw-r--r-- 1 nykysle nykysle 16 Aug 19 00:22 /home/nykysle/myfile
    >
    > but there is no link to it on the Desktop
    >
    > [nykysle@unimatrix ~]$ ls -l Desktop/myfile
    > ls: Desktop/myfile: No such file or directory
    >
    > And I want a link to it placed on /home/nykysle/Desktop.
    >
    > The only way it works is with this
    >
    > ln -s /home/nykysle/myfile /home/nykysle/Desktop/myfile
    >
    > Which is stupidly long winded. It must be possible and shorter to use
    > relative addressing.
    > It is purely academic now but I an annoyed that I can't find the
    > combination to make it work
    >


    What does work:

    cd ~
    ln -s ~/myfile Desktop/myfile

    It seems that the path to the target must be absolute, but the path to the
    link can be relative, which makes sense when you think about it.

    Jim

  7. Re: soft links across directoruies

    James Kerr wrote:

    > faeychild wrote:
    >
    >> David W. Hodgins wrote:
    >>
    >>> On Mon, 18 Aug 2008 11:15:10 -0400, faeychild
    >>> wrote:
    >>>
    >>>> All I wished to do was to make a link from $HOME/myfile to the Desktop.
    >>>> [nykysle@unimatrix ~]$ ln -s myfile Desktop/
    >>>
    >>> The paramaters are backwards. The existing item (target), that you are
    >>> making
    >>> a link to, goes first.

    >>
    >> Yes correct. I have a file in the home directory that I want to access
    >> from the Desktop
    >>
    >>> If the target is in the same directory, or you want
    >>> to use a different name, or create the link in a directory other then
    >>> the current directory, then the second parameter says what name the
    >>> symlink will have, in the directory where the symlink is being created.
    >>>
    >>> ln -s Desktop myfile

    >>
    >> If I try this
    >>
    >> [nykysle@unimatrix ~]$ ln -s Desktop myfile
    >> ln: creating symbolic link `myfile' to `Desktop': File exists.
    >>
    >> Well yes it does exist in the home directory.
    >>
    >> [nykysle@unimatrix ~]$ ls -l /home/nykysle/myfile
    >> -rw-r--r-- 1 nykysle nykysle 16 Aug 19 00:22 /home/nykysle/myfile
    >>
    >> but there is no link to it on the Desktop
    >>
    >> [nykysle@unimatrix ~]$ ls -l Desktop/myfile
    >> ls: Desktop/myfile: No such file or directory
    >>
    >> And I want a link to it placed on /home/nykysle/Desktop.
    >>
    >> The only way it works is with this
    >>
    >> ln -s /home/nykysle/myfile /home/nykysle/Desktop/myfile
    >>
    >> Which is stupidly long winded. It must be possible and shorter to use
    >> relative addressing.
    >> It is purely academic now but I an annoyed that I can't find the
    >> combination to make it work
    >>

    >
    > What does work:
    >
    > cd ~
    > ln -s ~/myfile Desktop/myfile
    >
    > It seems that the path to the target must be absolute, but the path to the
    > link can be relative, which makes sense when you think about it.
    >


    An alternative, that also works is:

    cd ~/Desktop
    ln -s ~/myfile

    Sometimes it helps to read the man pages.

    Jim


  8. Re: soft links across directoruies

    James Kerr wrote:

    > ln -s myfile Desktop/myfile

    This creates a link that points to itself
    cd Desktop
    lrwxrwxrwx 1 nykysle nykysle 6 Aug 20 09:41 myfile -> myfile
    and flashes
    --
    faeychild

  9. Re: soft links across directoruies

    James Kerr wrote:

    > faeychild wrote:
    >
    >> David W. Hodgins wrote:
    >>
    >>> On Mon, 18 Aug 2008 11:15:10 -0400, faeychild
    >>> wrote:
    >>>
    >>>> All I wished to do was to make a link from $HOME/myfile to the Desktop.
    >>>> [nykysle@unimatrix ~]$ ln -s myfile Desktop/
    >>>
    >>> The paramaters are backwards. The existing item (target), that you are
    >>> making
    >>> a link to, goes first.

    >>
    >> Yes correct. I have a file in the home directory that I want to access
    >> from the Desktop
    >>
    >>> If the target is in the same directory, or you want
    >>> to use a different name, or create the link in a directory other then the
    >>> current directory, then the second parameter says what name the symlink
    >>> will have, in the directory where the symlink is being created.
    >>>
    >>> ln -s Desktop myfile

    >>
    >> If I try this
    >>
    >> [nykysle@unimatrix ~]$ ln -s Desktop myfile
    >> ln: creating symbolic link `myfile' to `Desktop': File exists.
    >>
    >> Well yes it does exist in the home directory.
    >>
    >> [nykysle@unimatrix ~]$ ls -l /home/nykysle/myfile
    >> -rw-r--r-- 1 nykysle nykysle 16 Aug 19 00:22 /home/nykysle/myfile
    >>
    >> but there is no link to it on the Desktop
    >>
    >> [nykysle@unimatrix ~]$ ls -l Desktop/myfile
    >> ls: Desktop/myfile: No such file or directory
    >>
    >> And I want a link to it placed on /home/nykysle/Desktop.
    >>
    >> The only way it works is with this
    >>
    >> ln -s /home/nykysle/myfile /home/nykysle/Desktop/myfile
    >>
    >> Which is stupidly long winded. It must be possible and shorter to use
    >> relative addressing.
    >> It is purely academic now but I an annoyed that I can't find the
    >> combination to make it work
    >>

    >
    > What does work:
    >
    > cd ~
    > ln -s ~/myfile Desktop/myfile
    >
    > It seems that the path to the target must be absolute, but the path to the
    > link can be relative, which makes sense when you think about it.
    >
    > Jim

    This one works fine. I thought I'd tried that combination in my despair, but
    it was all happening in the middle of the night so who knows.

    It's odd though, I would have sworn that when run from the directory containing
    the target file ( the file to be linked too ) then

    ln -s myfile Desktop/
    should have worked.. Well it seemed logical at midnight. Man files are very
    cryptic after the witching hour and google points to man files.


    Thanks Jim


    --
    faeychild

  10. Re: soft links across directoruies

    faeychild wrote:

    > I always do this to myself in the middle of the night. A five second job
    > turns into an hour of mystery, man pages, googling and banging head on
    > keyboard.
    >

    You are not alone in that. Any time that you are tired is not the best
    time.

    Doug, alias Murphy.

+ Reply to Thread