Mourning the loss of our friend, WhitPhil.
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
 
Linux and Unix
Tag Cloud
access audio black screen blue screen boot bsod connection crash dell desktop drivers dvd email error excel excel 2003 firefox hard drive hardware hdmi hijackthis internet keyboard laptop malware monitor motherboard network networking outlook problem recovery router safe mode screen slow sound spyware tdlwsp.dll trojan vba video virus vista vundo windows windows 7 windows vista windows xp wireless
Search
Search for:
Tech Support Guy Forums > Operating Systems > Linux and Unix >
Can someone explain Hard and Symbolic links purpose?

Tip: Click here to scan for System Errors and Optimize PC performance
[ Sponsored Link ]

Closed Thread
 
Thread Tools
bassetman's Avatar
Computer Specs
Moderator - Gone, but never forgotten with 48,307 posts.
 
Join Date: Jun 2001
Location: Great White North (WI)
Experience: Getting somewhere I hope
11-Mar-2003, 03:57 PM #1
Can someone explain Hard and Symbolic links purpose?
I am taking an online Red Hat 8 course. They are covering hard and symbolic links now and I fail to see the use for these.
Couldn't you just link to whatever file in the program or HTML rather than at the Shell level?

Here is what they have to say.
PHP Code:
You can use "links" to access files in an ext2 filesystem.

Links are created between files using the "ln" command.

ln <option> <target> [<link name>]

    
The <targetparameter specifies the name of the file to link to.

    
The optional <link nameparameter is the name that you want assigned to the link.

You can create two types of link:

a hard link
a symbolic link 
__________________
Bush on 911.....What Rice and Powell said about WMDs!.....Learn about Human Rights
..."Blessed is the man, who having nothing to say, abstains from giving wordy evidence of the fact."
-George Eliot (1819-1880), author.
codejockey's Avatar
Senior Member with 1,410 posts.
 
Join Date: Feb 2002
11-Mar-2003, 07:58 PM #2
This may be MTYWTK (more than you want to know) so feel free to disregard as appropriate ...

The original purpose of a link was to allow a file (normally, an executable file) to be accessed by two or more different names. This might come in handy when the behavior of the executable changed depending upon how it had been invoked. For example, the Unix editor vi could be invoked as vi or as view; if invoked as view, the specified file was opened in read-only mode, and the user did not have to remember whatever option was normally required to invoke vi in a read-only mode (of course, the code within vi had to check how it was invoked in order to determine how to behave). Similarly, a program might expect a file to be in a specific location (i.e., hardcoded). If your system were organized differently, and that file resided somewhere else, a link allows you to create a "virtual file" in the location expected by the program, without actually copying or moving the file from its current location.

A hard link was the original type of link. It works by using a a directory entry that points to the same inode for the file being linked to. For example, if the inode for vi is 12498, then the directory information for view will show inode 12498 as the first inode associated with the file. Because hard links use inodes to link files, they can only be used to link files within the same filesystem (i.e., you cannot hard-link a file in /var to a file in /home if /var and /home are separate filesystems).

Berkeley versions of Unix introduced the concept of the symbolic link. The major advantage of this type of link was that it allowed linking across filesystems. The result is the same, however -- two or more files can be accessed by the same name.

Linux makes extensive use of symbolic links, so that various programs will find things where they expect. For example, /usr/tmp is often linked to /var/tmp, so that System V-based programs will find temporary filespace where they would normally look for it.

Note that this sort of "link" is not the same as an HTML "link" (i.e., anchor or similar). The HTML link is really a reference to another file; the hard or symbolic link is a reference to the same file.

Hope this helps.
__________________
The slowest component still sits at the keyboard.
bassetman's Avatar
Computer Specs
Moderator - Gone, but never forgotten with 48,307 posts.
 
Join Date: Jun 2001
Location: Great White North (WI)
Experience: Getting somewhere I hope
11-Mar-2003, 08:08 PM #3
Ok, that helps a lot.

So I could, say, create a link for a location that a .PL file or CGI script was looking for rahter than having to edit the whole script(s)?

Or am I now stretching the limits!

Thanks a lot CJ
John
codejockey's Avatar
Senior Member with 1,410 posts.
 
Join Date: Feb 2002
12-Mar-2003, 05:38 PM #4
Absolutely, you could -- and this sort of thing is done fairly often. You're not pushing the limits at all.

And a slight correction: in my earlier post, I meant to say that "the result is the same, however -- two or more names can be used to access the same file." Instead, what I said was that two or more files could be accessed by the same name. Although this is technically true, it has nothing to do with links, and in general is a bad idea. Apologies for the confusion.

Hope this helps.
__________________
The slowest component still sits at the keyboard.
Closed Thread Bookmark and Share

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Smart Search

Find your solution!



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.

Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 05:02 AM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.
Powered by Cermak Technologies, Inc.