Download your favorite Linux distribution at LQ ISO.
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 01-08-2006, 10:06 PM   #1
LQ Newbie
Registered: Jan 2006
Posts: 1

Rep: Reputation: 0
Thumbs up Hard and Soft linx....Expalnarion needed........

Dear Moderato r,
I'm a new commer to LInux and there arec some issues occured during using program environment..

I have issue on HArd links and soft links of Linux...
PLz let me know good discription about it without any confusions..
Thank you....
Old 01-08-2006, 10:19 PM   #2
Senior Member
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,138

Rep: Reputation: 166Reputation: 166
There's an explanation at which may help you.
Old 01-09-2006, 03:36 PM   #3
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,671

Rep: Reputation: 218Reputation: 218Reputation: 218
Moved: This thread is more suitable in Linux-Newbie and has been moved accordingly to help your thread/question get the exposure it deserves.

The biggest difference (from the user point of view) between soft- and hard links is that you can use soft links between different partitions, but not hard ones.

Hard links are like 'having' a file in a specific directory. Files are not connected to directories, hard links represent the connection. Symbolic (soft) link is, in fact, an entry with file name with path, that's interpreted correctly when needed.
Old 01-09-2006, 06:36 PM   #4
LQ Guru
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 9,078
Blog Entries: 4

Rep: Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170
You know how you can put a "Shortcut" on the desktop in Windows? How you can have several "shortcuts" all pointing to the same thing?

A symbolic link (which is the only kind of link you'll need) is like that: it's a reference to another file or directory ... by name. When you use the symlink Linux immediately and invisibly translates that to a reference to the corresponding file or directory.
Old 01-10-2006, 05:27 AM   #5
Registered: Nov 2005
Distribution: xubuntu, grml
Posts: 451

Rep: Reputation: 37
the commands for it:
ln source destination
Create a hard link called destination to the file called source. 
The link appears as a copy of the original files, but in reality only one copy of the file is kept, 
just two (or more) directory entries point to it. Any changes the file are automatically visible throughout. 
When one directory entry is removed, the other(s) stay(s) intact. The limitation of the hard links are: 
the files have to be on the same filesystem, hard links to directories or special files are impossible.

ln -s source destination
Create a symbolic (soft) link called "destination" to the file called "source". 
The symbolic link just specifies a path where to look for the file. In contradistinction to hard links, 
the source and destination don't not have to tbe on the same filesystem. In comparison to hard links, 
the drawback of symbolic links are: if the original file is removed, the link is "broken", 
symbolic links can also create circular references (like circular references in spreadsheets 
or databases, e.g., "a" points to "b" and "b" points back to "a").
Old 01-10-2006, 06:42 AM   #6
Registered: Oct 2004
Location: Belgium
Distribution: Slackware 13.37
Posts: 512

Rep: Reputation: 31
Originally Posted by muha
hard links to directories or special files are impossible.
I always thought the ./ and ../ in a directory are hardlinks to the parent directory?
Old 01-10-2006, 07:53 AM   #7
Registered: Oct 2005
Location: Oxford, UK
Distribution: Debian Etch (w/ dual-boot XP for gaming)
Posts: 282

Rep: Reputation: 31
I'm not sure they are, since I think it's true (as noted above) that you can't hardlink to a file on a different partition. With that in mind, you wouldn't be able to have a ../ in the top directory of any partition - but the /home directory will always have a ../ linnking back to /, even if it has its own dedicated partition.

Though I must admit I've never wondered exactly how they're implemented, I've always been happy to use them as-is!
Old 01-10-2006, 09:06 AM   #8
Senior Member
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
"." can be looked at as a hardlink of the directory itself.
Likewise, ".." is similar to a hardlink to the parent directory. That's why the link count of a directory
(see ls -l) is increased by 1 when you create a subdirectory (the subdir's .. entry is an extra link).

The internal mechanism can be simplified to:
-Every object has it's own inode, a memory structure that define's it's size, permissions and alike.
-Directories contain a list of inode - name pairs of all the objects that are part of the directory. So, they
contain something like (inodes are typically referenced by a number):
xxx subdir_1
yyy file_1
zzz subdir_2
-Directories also contain 2 special entries, "." and "..". The inode associated with the name "." is the inode
of the directory itself (think of it as a "link" to it's own inode).
The inode associated with ".." is the inode of the parent directory.
-A hard link is nothing more than such a similar directory entry, using the inode of a file (or dir (?)) that
already exists on the disk. That's why you can't have hard links to other partitions. Each partition has it's
own set of inodes. So with hard links you're having multiple directory entries pointing ("linking") to the
same object on disk, just like with the ".." entry.
-A soft link is different. You can think of it, as mentioned above, more as a small file that contains the full
path to another file/directory anywhere on your filesystem. For the soft link to work, the file/dir that's
pointed to must exist and the path leading to it must be searchable.

Partition mount points is a different story. It suffices to say that whenever you cross a mount point in a path, ie by doing "cd .." in the partition's top directory like in Dtsazza's example, the mount configuration
is used to get you to the right location instead of the directory's entries. The ".." and "." entries of such a mount point directory should point to the directory itself (I think). Simply consider the possibility of mounting the /home partition as the root partition (under "/" instead of "/home"), in which case the "." and ".." entries of / still need to point to / itself for consistency.


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
Soft vs. Hard Links jrdioko Linux - Newbie 2 06-13-2004 02:41 PM
Hard/Soft Links nodger Linux - General 1 05-15-2004 10:36 AM
Which do you prefer. Hard / soft copy text? unholy General 7 04-14-2004 05:37 PM
getrlimit is setting soft and hard limits to -1, why? FunkMeisterMaz Programming 2 03-22-2004 06:34 AM
Linx Email Server Setup Help needed clickaway Linux - Newbie 1 12-10-2003 02:24 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:15 AM.

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