Unable to remove symlink from cygwin

0

I installed cygwin64 on my PC and then from terminal created some symlinks like this:

%ln -s /cygdrive/c /c
%ln -s /cygdrive/z /z

After that by mistake I created wrong link:

%ln -s /cygdrive/x /z

and

%ln -s /cygdrive/z /z

Then I realized it and wanted to remove 'x' and 'z' symlink but failed.

I have this picture:

pwd: /cygdrive/z
$ ls -l
total 58
drwxrwx---+ 1 VHA01+User(214401) Domain Users      0 Sep 23 16:28  abcLZ
-rwxrwx---+ 1 Unknown+User       Unknown+Group  1404 Jan 13 22:20 'Shortcut to abcLZ.lnk'
-rwxrwx---+ 1 Unknown+User       Unknown+Group 47104 Dec 13 15:06  Thumbs.db
lrwxrwxrwx  1 Unknown+User       Unknown+Group     1 Jul 31 08:12  x -> z
lrwxrwxrwx  1 Unknown+User       Unknown+Group     1 Jul 31 08:12  z -> z
--
pwd: /cygdrive/z
$ rm x
rm: remove symbolic link 'x'? yes
rm: cannot remove 'x': Permission denied

vhabhsvoldme@BOS-WSRES186018 /cygdrive/z
$ rm /cygdrive/z/x
rm: remove symbolic link '/cygdrive/z/x'? y
rm: cannot remove '/cygdrive/z/x': Permission denied
--
pwd: /cygdrive/z
/cygdrive/z
$ chown <myaccount> x
chown: cannot dereference 'x': Too many levels of symbolic links
***

Hence I'm stuck and can't remove symlink 'x' and 'z'. Could anyone please help me to get rid of it? Thanks

susik

Posted 2020-01-24T19:30:55.923

Reputation: 447

have you tried ro remove it with explorer or CMD ? – matzeri – 2020-01-24T20:22:41.500

Yes, I tried cmd and explorer but nothing helped. Btw ... if I uninstall Cygwin and than install it again... will it solve my issue? – susik – 2020-01-25T20:35:59.657

No. The file is not in the distribution. Try rm z and than rm x – matzeri – 2020-01-26T07:30:15.673

The problem is likely due to Z being a network drive with strange permissions. On a local drive you should not see ever Unknown+User Unknown+Group for file created by yourself. – matzeri – 2020-01-26T07:33:36.880

>

  • matzeri, You are absolutely correct. Z is a network drive with strange permissions. I tried to follow your steps. I was able to delete z. After that I did not see x anymore ( because it was under z. I had to create z link again because I need it. After that I again see x. Hence ... it did not work for me. Any other ideas? Thanks
  • < – susik – 2020-01-26T16:28:25.423

    => ln -s /cygdrive/z /z

    => ls -l z/? lrwxrwxrwx 1 Unknown+User Unknown+Group 1 Jul 31 08:12 z/x -> z lrwxrwxrwx 1 Unknown+User Unknown+Group 1 Jul 31 08:12 z/z -> z | => cd z total 58K drwxrwx---+ 1 VHA01+User(214401) 0 Jan 24 09:41 LimsLZ/ -rwxrwx---+ 1 Unknown+User 1.4K Jan 13 22:20 'Shortcut to LimsLZ.lnk' -rwxrwx---+ 1 Unknown+User 46K Dec 13 15:06 Thumbs.db lrwxrwxrwx 1 Unknown+User 1 Jul 31 08:12 x -> z lrwxrwxrwx 1 Unknown+User 1 Jul 31 08:12 z -> z => rm x rm: remove symbolic link 'x'? yes rm: cannot remove 'x': Permission denied – susik – 2020-01-26T16:36:50.220

    The problem is not in Cygwin but in the permission in the Network drive. It allows to create files but does it with obscure ownership. Avoid it when using cygwin and just use you local drive. Eventually you can ask an Administrator to remove your experiment from the server. – matzeri – 2020-01-26T17:48:33.383

    Exactly! My administrator removed it front server. Thanks for heads up. I am all set now. – susik – 2020-01-27T23:48:07.373

    Answers

    0

    Thanks to matzeri The solution was to remove the link on server

    susik

    Posted 2020-01-24T19:30:55.923

    Reputation: 447