File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Linux / UNIX and the fly likes What's a symbolic link for? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "What Watch "What New topic

What's a symbolic link for?

Timothy Sam
Ranch Hand

Joined: Sep 18, 2005
Posts: 751
I thought it was similar to creating a shortcut in windows, but it doesn't seem that way... What is it for?

"ln -s Makefile.i386_gcc Makefile"

SCJP 1.5
Martin Simons
Ranch Hand

Joined: Mar 02, 2006
Posts: 196
Yes it is something like a shortcut. After that command, whenever you
access Makefile you will actually be accessing the file Makefile.i386_gcc.
Gerardo Tasistro
Ranch Hand

Joined: Feb 08, 2005
Posts: 362
The ln command allows you to link a file name in one position of your file system to a file name in another position. It isn't anything like a shortcut in Windows. A lnk file in Windows has information that says where the file it points to is. If you open the shortcut you get that info, not the info in the file you point to. With a link you do get the info inside the file pointed to.

Sample usages are:

Pointing to a required file with another name. Say for example I use a program that requires a /lib/ file, but I have just upgraded other stuff and replaced V 4.3 with V 5.1. My file system no longer has It has Which is backward compatible to V 4.3, but not the same. I can use ln to create a link from /lib/ to /lib/ Now I have a real file 5.1 and a link 4.3 to 5.1. This saves space and is much easier to maintain.

Site updates are a breeze with the ln command. Well not so much with Java, but php and the sort yes. I can have a virtual host in my apache running off the "mysite". The mysite dir is a symbolic link to mysite3.1. I can work on mysite4.0 and when I'm ready switch the link of mysite from mysite3.1 to mysite4.0 and be done with it.

Site security and administration is also easy with ln. For example I can ln the images or styles directory to a user account. Allowing said user to ftp new images and style sheets into those directories without touching the code. During development phases I can outsource development and still share confidential code. By using links I can allow apache to run scripts and code, but still hold my contractors within a jail in which they can't see what I developed. They can only call it through apache. BTW, this I know in php. Don't know how it would be done with Java.
I agree. Here's the link:
subject: What's a symbolic link for?
It's not a secret anymore!