ericosg ericosg - 2 years ago 135
Linux Question

Convert file or directory to symbolic link and preserve permissions

I have

drwxr-x--- eric:nobody
as the mod and ownership.

I login with
so I cannot recreate this folder without root access, since
is not part of the

I want to replace my
with a symbolic link (i.e.
ln -s ~/git/project/src ~/public_html
) but if I do that, my new
ends us without the correct permissions.

Is there a trick to get around this without contacting my admin?

Answer Source

Possibly by doing the following:

  1. Copy everything from ~/git/project/src into ~/public_html
  2. mv ~/git/project/src ~/git/project/src2 to get it out of the way
  3. mv ~/public_html ~/git/project/src
  4. finally link it back: ln -s ~/git/project/src ~/public_html

The idea is to keep the original public_html directory because it has the correct owner/permissions, but reuse it as the link target.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download