• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Symbolic Links for executables

 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys,

What are these symbolic links actually? As I was reading through a book for the Linux+ certification, it is stated that the executable for the vi editor is actually placed under the /bin directory and a symbolic link is located under /usr/bin/ directory which in turn points to the executable located under /bin? What does this symbolic link mean?
 
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jothi,

symbolic links in UNIX/Linux work basically like shortcuts in Windows. You can create an alias for a file or directory at a different location instead of creating a physical copy of the file or directory. For your example this means that you only have to maintain one copy of the vim executable but the use can find vim in both mentioned directories because the second one is a link to the first one ;-)

Marco
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, they don't work like .lnk-Files in Windows. (or is "shortcut" something new?)

a) Are symbolic links older than Windows-links, so if at all Windowslinks work like the unix ones. But they don't. b) A windows-link is a file which contains the information to where it links, while symbolic links on linux are a concept of the filesystem.

If you copy a symbolic link on windows to your USB-Stick, and try to use it later, you will be frustrated - it is just the .lnk-File, not the file it should link to.

The linux/unix link is much more useful, i.E. the link behaves as if it where the original file. It just doesn't consume the diskspace - it's like a reference or an pointer to an somewhere else specified object.
 
Marco Ehrentreich
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, with shortcuts I meant the same as .lnk files. Not sure how they are called in English but I think it was shortcut.

And sorry for not going into details for the sake of an easy to understand answer. Of course symbolic links in UNIX are not the same as those Windows shortcuts because the whole organization of the file system works differently. I just said they basically work like the said shortcuts. I know that a lot of Linux commands let you choose if a symbolic link itself is copied/moved/etc. or the file it references, but I thought these details wouldn't make it easier for Jothi to understand what symbolic links are. Everyone working with Linux will soon realize that there are many more things regarding the file system which work different than on Windows.

Although I'm aware of the fact that UNIX-like systems were there long before Windows was invented. In fact it's interesting how many internal concepts in a modern Windows OS are very similar to those that have been used in UNIX systems many years before.


Marco
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks guys!
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are 2 ways that symbolic links are useful in Linux (and the other *n*x OS's) for executing programs.

1. As a simple alias. For example, people are used to invoking "vi", but there are actually a number of vi-like editors out there. Often the "vi" on a Linux system is really vim. But since "vi" is the generic name, it makes life (and how-to books) easier to alias "vi" to be a shortcut to starting vim. A lot of people don't even realize they're not really runnin vi until they encounter a system where "vi" brings up the real vi. Likewise, some systems allow you to invoke Perl as either /usr/bin/perl or /bin/perl.

2. As a convenience feature. A good example is the ldapmodify prorgam. It has an alias of "ldapadd". When you run this utility, the startup code looks at the name you used. If you started it using the "ldapadd" name, the add mode features are automatically switched on.

Perhaps the most extreme example of aliasing is the BusyBox utility. BusyBox is an all-in-one program that provides the basic functions of a host of Unix utilities. It's intended for use in settting up minimal systems where disk space may be limited, and it allows you to install them all by copying a single file. A lot of Unix utilities have common functionalities, so you can save significantly by only having one copy of them.

So when you invoke grep, you run BusyBox and it runs its grep utility. Invoke it from the sed alias, you get sed, and so forth.
 
Stefan Wagner
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Symbolic links on linux are not limited to executable programs. You may put a symbolic link to an image, a soundfile, a directory, and so on.

Afaik, lnk-files are very limited on Windows. Can you open an Image-LNK with MS-Gimp? Step into a directory?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic