Follow us on...
Follow us on Twitter Follow us on Facebook
Register
Results 1 to 8 of 8
  1. #1
    Powermaster's Avatar
    Powermaster is offline Site Supporter
    Join Date
    Dec 2001
    Location
    ATA Bus 0 Dev 0
    Posts
    185
    Thanks
    1
    Thanked 0 Times in 0 Posts

    How to make Symbolic Links

    How would one go about making a Symbolic Link?

    Thanks

  2. #2
    hazmat's Avatar
    hazmat is offline Rusher of Din
    Join Date
    Oct 2001
    Location
    Brooklyn, NY
    Posts
    1,803
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here's an example. vi is in
    /usr/bin/vi . You want a sym link to point to it from the same directory called vii. While in /usr/bin, you would type:

    ln -s vi vii

    You could specify absolute pathnames as well, so if you wanted a sym link called 'vi' in /usr/local/bin pointing to /usr/bin/vi , if you were in /usr/local/bin, you could type:

    ln -s /usr/bin/vi vi


    Does this make sense?

  3. #3
    Eckhart is offline Baron in the Trees
    Join Date
    Jul 2002
    Posts
    67
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes, what 'ln' basically does is to write arg1 into a file called arg2 and flag the latter as a symbolic link.

    Yet, by reading your post, I stumbled across some odds in MacOSX. I wanted to display the symbolic link as such, but not the file it is linked to. I know I was doing that somehow a whole while ago (not on MacOSX) and now I can't remember.

    I tried a lot... I pentrated cat, od, file;
    I messed with the "symlinks" option in tcsh. I tried to acces the file through its inode:
    find ./ -inum 374355 -exec cat "{}" \;

    But whatever I do, the system will always follow the symbolic link. HRRFF!

    The same for directories, MacOSX will not allow to dump a directory to stdout using "od -c" for example. Whatever I do here, it keeps saying ".. is a directory".

    The third question: Is any command line method known to you that flags a file as a symbolic link?

    Thanks a lot!

  4. #4
    lurk's Avatar
    lurk is offline Mitä?
    Join Date
    Mar 2002
    Location
    Land o' skeeterz
    Posts
    2,087
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Eckhart's description of what ln does is not actually correct. The way that a symbolic link is recorded in the file system is dependent on that filesystem. You are assuming an implementation which does not correspond to what is done in HFS+.

    Now on my old AT&T 3B1 I could do what you describe but that would not work on many newer file systems because the representation of the directory is more complex. For instance some file systems directly record the symbolic link in the directory structure itself.

    Finally, the assumption that there is actually a "directory listing file" does not hold for all file systems. The implementation you are describing in particular does not handle accessing long absolute paths well. Each path component has to be looked up in each directory along the way by a linear search which is basically a O(n*m) operation where n is the number of path components and m is 1/2 the average number of files in a directory. In comparison OS/@'s old HPFS file system used a balanced B-tree so such a search would take O(log(total files)) time (IIRC). The latter case has much better performance characteristics but therein directories are not explicitly stored, they are built on the fly from the individual entries. (Another neat thing if you have ever used zsh doing wild-inferiors was just as cheap as globbing. That is /foo/*.c was a fast as /**/foo.c which normally under unix requires a call to find to compute.)

    -Eric
    Wenn ist das Nunstruck git und Slotermeyer? Ja!...
    Beiherhund das Oder die Flipperwaldt gersput!

  5. #5
    Eckhart is offline Baron in the Trees
    Join Date
    Jul 2002
    Posts
    67
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by lurk
    You are assuming an implementation which does not correspond to what is done in HFS+.
    So what is it then? What I see on my box, when I create a symbolic link is an autonomous file (with its own inode) with the length of exactly the source path plus a certain flag.

    For instance some file systems directly record the symbolic link in the directory structure itself.
    Wow, I didn't know that. Which are these?

    therein directories are not explicitly stored, they are built on the fly from the individual entries.
    See, I'm really a rookie on filesystems, that is also new to me. But this is HPFS and not HFS+ is it?

    (Another neat thing if you have ever used zsh doing wild-inferiors was just as cheap as globbing. That is /foo/*.c was a fast as /**/foo.c which normally under unix requires a call to find to compute.)
    Same for tcsh and bash.

    --
    Is now anyone here, who can answer my actual questions? Thanks again!

  6. #6
    Arden's Avatar
    Arden is offline Where mah "any" keys at?
    Join Date
    Dec 2002
    Location
    Spokane, WA
    Posts
    7,752
    Thanks
    0
    Thanked 1 Time in 1 Post
    The easiest way to create a symbolic link I know of is to download & install Cocktail, click on Files and the Links tab, and drag a file onto the button with the terminal alias on it.
    Systems:
    2.5 GHz MacBook Pro Core 2 Duo, 4 GB RAM, 320 GB hard drive, runs 10.6.8
    1.6 GHz iMac G5, 1.5 GB RAM, 120 GB hard drive, runs 10.4.11 (out of commission)
    iPhone 4, 16 GB, iOS 4.3.5

  7. #7
    lurk's Avatar
    lurk is offline Mitä?
    Join Date
    Mar 2002
    Location
    Land o' skeeterz
    Posts
    2,087
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by Eckhart
    So what is it then? What I see on my box, when I create a symbolic link is an autonomous file (with its own inode) with the length of exactly the source path plus a certain flag.
    I guess my point is that it was a symbolic link and you are not guaranteed anything about how it was implemented. For instance under HFS+ it may well be a file (I don't know but it certainly seems reasonable).


    Wow, I didn't know that. Which are these?
    I remember that from my OS class of many many winters ago, I can't say that I remember the exact file system. The basic idea was that the target of the symbolic link was stored in filename slot of a directory entry and then had a bit set flagging it as "not a real file name". A symbolic link then did not index into the set of inodes but rather the directory index which contained the target.

    The real moral of this is that with all the different implementations of this stuff over the ages for almost any cockamamy way you can come up with doing something somebody did it.


    See, I'm really a rookie on filesystems, that is also new to me. But this is HPFS and not HFS+ is it?
    Yes it is HPFS and I think that is part of the reason that there were never any Linux drivers able to write HPFS. It was just too different, that said I believe that NTFS has inherited some of these features and is in a similar situation of partial support.

    I honestly just don't know what HFS+ does I haven't had reason to look it up.

    Same for tcsh and bash.
    Nope you misunderstood the ** that will match any number of arbitrarily nested directories. So /foo/**/bar.c would match /foo/baz/quuz/zot/bar.c which is not possible in bash or tsch. In those cases you have to use find to grovel over the directory for you. Another point is that this is very sow by comparison and on something like HPFS a wild inferiors match like above would be super fast.


    Is now anyone here, who can answer my actual questions? Thanks again!
    Well I thought I did in an obtuse sort of way which is to say you cannot in general do what you are trying to do. I also know this from experience in trying to use a combination of dd and fsck to delete an undeletable file. Nothing says that you can cat a directory or a symlink on any filesystem on any given unix. Now it may work on some implementations like my old 3b1 but it is just an accident really.

    On a side note if I can write a directory via cat like you could in the old old days that also means that I can own the box. All I have to do is copy a shell into a directory, make it setuid me and then edit the directory file to change that little uid to root's. Now I am root and on my merry way.

    Note to moderators that is not really a description of how to hack a box as it would not work on any modern computer.

    So what are you really trying to do? Just make a symbolic link, that was already answered. Convert a normal file into a symlink using its contents as a target via some backdoor way?

    -Eric

  8. #8
    Eckhart is offline Baron in the Trees
    Join Date
    Jul 2002
    Posts
    67
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Without bringing it up at large, my questions were:

    1. How do I make the system (in whatsoever way - and regardless to all the implementations over the ages it is not working on) to stop following symbolic links?
    2. Is any "hack" known to somebody how I can dump a directory to stdout? As it was once possible -and not only one system- with "od -c".

    Ok, and most about your point was basically that we cannot find a patent remedy due to all these different implementations and filesystems... -- which is an euphemism for "NO" to both questions.

    Well, anyways I didn't want to bother, if the answer doesn't come handy, I did not want to start a major thread. It was just the idea that somebody would know.

 

 

Similar Threads

  1. Replies: 2
    Last Post: August 31st, 2003, 07:10 AM
  2. symbolic links via web
    By macidiot in forum Design & Media
    Replies: 0
    Last Post: January 29th, 2003, 05:05 PM
  3. How to compile stuff
    By fintler in forum Unix & X11
    Replies: 1
    Last Post: August 28th, 2002, 07:57 AM
  4. Apache config Q / symbolic links Q
    By andypeter in forum Mac OS X System & Mac Software
    Replies: 2
    Last Post: April 18th, 2001, 01:33 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •