Linux - NewbieThis 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!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
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.
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.
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").
Distribution: Debian Etch (w/ dual-boot XP for gaming)
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!
"." 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):
-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.