Linking Files: Hard Link vs. Soft Link?
Smoot Carl-Mitchell
smoot at tic.com
Tue Apr 14 18:28:33 UTC 2009
On Tue, 2009-04-14 at 19:45 +1200, Tim Frost wrote:
> > Is it possible to create a hard link to a directory somehow?
>
> No. In general, a directory is a container, and as such it defines a
> place in the tree which holds files (and other directories). That
> container only makes sense in that one place in the tree.
Hardlinks to directories are not allowed, except when creating a
directory. A hard link is created to a new directory's parent directory
with the name ".." and linked to itself with the name ".". This
standard is the way the utilities walk up the filesystem hierarchy. The
"/" directory has the ".." hardlink point to itself.
This is the only case where hardlinks to directories appear in the
filesystem hierarchy. Some Unices do allow userland programs to create
directory hardlinks, but it is inadvisable to do this, since many of the
standard utilities depend on this not being the case. You can see the
hardlink count with the ls -la command. The -a lets you see the
directory links and all the hidden files in a directory. The link count
is the number after the permissions. A directory with lots of
subdirectories will have a lot of hardlinks. Adding "-i" as an option
will let you display the inode number which is the only unique
identifier for each file.
--
Smoot Carl-Mitchell
Computer Systems and
Network Consultant
smoot at tic.com
+1 480 922 7313
cell: +1 602 421 9005
More information about the ubuntu-users
mailing list