3

I'm trying to create a hard link to a directory as follows

root@...:/usr/share/tomcat6/logs# ln --directory /usr/share/tomcat6/skel/conf conf

It fails with the following error

ln: creating hard link `conf' => `/usr/share/tomcat6/skel/conf': Operation not permitted

What am I missing? How can I create the equivalent of this directory link?

hawkeye
  • 3,827
  • 6
  • 28
  • 27
  • 1
    Possible duplicate of [Why are hard links not allowed for directories?](http://askubuntu.com/questions/210741/why-are-hard-links-not-allowed-for-directories) – Amir Ali Akbari Mar 28 '16 at 11:59

2 Answers2

5

From the manual page of 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)

An application cannot see whether a hard link is a hard link or the original file path. If this is not a requirement, you can use symbolic links instead:

ln -s /usr/share/tomcat6/skel/conf conf
Lekensteyn
  • 171,743
  • 65
  • 311
  • 401
1

it is a very bad idea, but you can do this using debugfs:

debugfs -w /dev/sdXY
debugfs: ln /usr/share/tomcat6/skel/conf /usr/share/tomcat6/logs/conf
debugfs: quit
ls -ld conf
jp_
  • 11
  • 2
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 02 '23 at 09:44