View the Most Wanted LQ Wiki articles.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 03-01-2009, 11:08 PM   #1
Registered: Mar 2009
Posts: 47

Rep: Reputation: 15
Linux command ln

I understand the whole process of what the command ln does which is the following for an example:

~ ]$ ln file1 file
~ ]$ ln file1 file3

This means that file1 is hard linked to file, and file1 is also hard linked to file3. Correct? If this is the case, file, file1, and file3 are all one file, which means the total file size would be just one amount. Am I understanding this correct?
Old 03-01-2009, 11:21 PM   #2
LQ Guru
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 5,986

Rep: Reputation: 1444Reputation: 1444Reputation: 1444Reputation: 1444Reputation: 1444Reputation: 1444Reputation: 1444Reputation: 1444Reputation: 1444Reputation: 1444
Come with me to the land of file-system implementation. Let's briefly talk about how a file-system works...

Physically, Linux thinks of a filesystem as storing information in abstract things called inodes, each of which is identified by a unique number. So, every "file" is an "inode."

(Again, conceptually...) a "directory," then, is just a somewhat-special kind of file that contains a list of file-names and the corresponding inode-numbers. The computer looks-up the file by name, finds the inode, and uses that to reach your data.

Now... what would happen if two directory-entries pointed to the same inode? Is that "okay?" Yes. Is it "a problem?" No... it is a "hard link." You have two different directory entries... hence, two file-names at different points in the directory hierarchy... which are equivalent in that they all reach the same information.

Now, "that works, but it's cumbersome." A much better and more flexible way to do the same thing, in-practice, is provided by the notion of "soft," or "symbolic," links.

A "soft link" is simply (conceptually...) a directory-entry that refers to another file, by name. The computer looks-up the soft-link, grabs the file-name out of it, and silently locates and opens that file. The same essential purpose is achieved ... i.e. two directory-entries get you to the same data ... but it's done in a just-as-efficient and much-more-flexible way. Instead of having two directory-entries refer to the same inode, we have one directory-entry referring to the inode, while the other directory-entry refers (by name...) to the first directory-entry.

Of the two... you should always use soft links in practice. They just work much better in real life.
Old 03-01-2009, 11:27 PM   #3
Registered: Mar 2009
Posts: 47

Original Poster
Rep: Reputation: 15
Thanks for explaining that to me! I believe I have a better understanding of it now. Thanks again, I appreciate you taking the time to explain.
Old 03-02-2009, 07:14 AM   #4
Registered: Oct 2007
Location: MI
Distribution: Debian Slackware
Posts: 528

Rep: Reputation: 50
Here is a Link that will help also.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: The Linux Command Shell For Beginners: Fear Not The Command Line! LXer Syndicated Linux News 0 12-22-2008 07:30 PM
Translating windows pscp command to linux scp command help robward Linux - General 2 01-17-2008 07:02 AM
Require Linux/Perl equivalent command for windows Command alix123 Programming 7 08-19-2005 03:23 AM
unix command to linux command leonidas Linux - General 1 09-10-2004 01:40 AM

All times are GMT -5. The time now is 10:02 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration