2

I have a folder symlink to core files and a folder with my improvements like this:

  • core/ -> /some/distant/root/directory/core/
    • script_a.py
    • special/script_b.py
    • special/script_c.py
  • core-improvements/
    • special/script_b.py

What I want to do is to create third directory called improved-core/ (using bash script), where there is going to be the contents of core-improvements/ and recursively linked contents of core/ (I mean /some/distant/root/directory/core/):

  • improved-core/
    • script_a.py -> /some/distant/root/directory/core/script_a.py
    • special/script_b.py (from core-improvements/)
    • special/script_c.py -> /some/distant/root/directory/core/special/script_c.py

If I create it by hand using symlink to script_a.py, script_a.py calls script_b.py from the /some/distant/root/directory/core/special/ directory, not the one in improved-core/special/ directory.

So I suppose the hard links are needed here?


So far I created the following bash script, that works nicely for me, but it creates the symlinks instead of hardlinks:

cp -r core-improvements/ improved-core/ &&
cp -LnrsT core/ improved-core/

Then I tried to create hard links instead of symlinks by switching -LnrsT to -LnrlT, but I get the following errors:

cp: cannot create hard link 'improved-core/script_a.py' to '/some/distant/root/directory/core/script_a.py': Operation not permitted

I'm now completely lost how to solve the issue.

  • Are the two directories in same filesystem? Try to run df -h . in each of them to verify that. You can't make hard-links between filesystems. – Soren A Jul 1 at 10:32
  • Yes, they are in the same filesystem (all df outputs equals) – aleskva Jul 1 at 10:48
  • Update: the same issue is for ln vs. ln -s – aleskva Jul 1 at 11:10
  • ln vs ln -s is also hard-links versus soft/symbolic-links ... can you hard-link file a to file b in the same directory ? – Soren A Jul 1 at 11:32
  • Yes, I can create hard links inside any of these directories and when I log in (become) as /some/distant/root/directory/core/ user, I can ln here as well. I just can't ln in /some/distant/root/directory/core/ when I'm logged in (become) as core-improvements/ user – aleskva Jul 1 at 11:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.