 | Moderator - Gone, but never forgotten with 48,307 posts. | | Join Date: Jun 2001 Location: Great White North (WI) Experience: Getting somewhere I hope | | 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 <target> parameter specifies the name of the file to link to.
The optional <link name> parameter is the name that you want assigned to the link.
You can create two types of link:
* a hard link
* a symbolic link
| | Senior Member with 1,410 posts. | | | | 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. | | Moderator - Gone, but never forgotten with 48,307 posts. | | Join Date: Jun 2001 Location: Great White North (WI) Experience: Getting somewhere I hope | | 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 | | Senior Member with 1,410 posts. | | | | 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. |  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.
| You Are Using: |
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. | |
|