I would like to replace a directory with a symlink. For the directory itself I have full permissions (rwx), but for the parent directory I don't have write permissions (r-x).

Is this possible? The man page for ln states that -f removes existing destination files, which sounds like it would first would delete the directory, then fail to create the symlink, leaving me with nothing.

  • You can create first a symlink with a different name, and see if it works. – dr01 Jun 8 '16 at 11:14
  • It gives me "Permission denied", as expected. I was hoping for an atomic "replacement" command – Fabian Schmengler Jun 8 '16 at 11:16

If you don't have write permission in the parent directory, you can't make any changes in the parent directory; this includes deleting the target directory, and creating a symlink.

In any case, ln won't overwrite a directory, even with -f.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.