Results 1 to 10 of 12
I have heard that creating hard link to a directory is not possible however when reading the man page of "ln" the "-d/-f" option says hard link directories ( super-user ...
- 07-03-2009 #1
creating hard link to directory
I have heard that creating hard link to a directory is not possible however when reading the man page of "ln" the "-d/-f" option says hard link directories ( super-user only). Thus this mean the super user i.e root can create hard link to directory and not a normal user , If yes then you . Even on specifying the above options I get a operation not permitted for a super user.
Only if I could understand the man pages
Registered Linux user #492640
OS: RHEL4,5 ,RH 9,Ubuntu
- 07-03-2009 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,961
You can only hard link files (and I would assume this also goes for directories) if the source and target are on the same file system. You cannot hard link a file on one device to a directory on another device or partition (different file system).
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 07-03-2009 #3Linux User
- Join Date
- Jan 2007
- Location
- cleveland
- Posts
- 452
from "man ln"
"-d, -F, --directory
allow the superuser to attempt to hard link directories (note: will
probably fail due to system restrictions, even for the superuser)"the sun is new every day (heraclitus)
- 07-03-2009 #4
- 07-03-2009 #5I may not be Rubberman, but I've tried it.
Originally Posted by vickey_20
It cannot be done
But soft links work perfectly well.Can't tell an OS by it's GUI
- 07-03-2009 #6
but if it can't be done then why is there an intimation for the same in the man pages.
Only if I could understand the man pages
Registered Linux user #492640
OS: RHEL4,5 ,RH 9,Ubuntu
- 07-03-2009 #7Indicating that it will probably fail, even for root.
Originally Posted by vickey_20 
Originally Posted by wikipedia Can't tell an OS by it's GUI
- 07-03-2009 #8
ok got your point but it is not supposed to be there then why the heck is it metioned in the man pages in the first place. Are there any distribution of linux which support it , otherwise the presence of -d/f option doesn't make sense .
Only if I could understand the man pages
Registered Linux user #492640
OS: RHEL4,5 ,RH 9,Ubuntu
- 07-03-2009 #9Linux Guru
- Join Date
- Nov 2007
- Location
- Córdoba (Spain)
- Posts
- 1,513
Well, I am not a master on fs's but...
First thing to note is that linux != ln, even more, ln is not part of linux.
The GNU tools might run in a different number of operating systems with a variety of kernels. This depends on many things, but mainly the game is between the kernel and the file system driver (for whatever fs you are using). So, that "ln" of "df" can do it, doesn't mean that "linux" necessarily support that feature. And even if that was possible in linux, it doesn't mean that your file system will support it at all (just like vfat doesn't support linux/unix permissions).
There are some interesting readings about this around:
The Answer Gang 93: hard links
hard links to directories [LWN.net]
The main problem with hardlinking directories is that when you make a hard link, there's no difference between the names of a given file or directory. And the file remains accessible until you delete the last one (unlike with symbolic links). This can confuse the programs that walk recursively the directory tree, who knows where our rm -rf could end. Unlike with symlinks, you don't have to deference anything, virtually, the directory is just there like if you created it with mkdir, and whatever hangs inside it will be recursed as well.
Symbolic links on the contrary are easily identifiable and avoidable to deference when needed.
You see that on the man page because simply no one has ever forbidden that, and posix don't say anything against that either. But I know of no OS/fs that actually implemented the feature (that doesn't mean it doesn't exist, maybe it does). It just means that the linux kernel and native fs's do not support it.
Any distro supporting this, if there's any at all, will have a patched kernel for sure. AND -more importantly- don't expect that a standard linux fs created with such a distro (if it exists at all) will be mountable/readable/portable to other -standard- linux OSes. At least not without a previoius fsck.
- 07-04-2009 #10Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,961
Well, I tried it on my CentOS 5.3 and it fails with the error message "Operation not permitted". There may be linux versions that allow it, and it might be a factor of the file system in question. Don't know. Not sure I care.

So, why do you want a hard link to a directory?Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!




