Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to create symbolic link that points to it self - linux

Has anyone succeed to create a symbolic link that point to it self? I tried to create a symlink to some file delete the real file and try to link to it self but got this error:

ln: creating symbolic link `********': File exists

I know its possible to create this symlink.

like image 596
itzikos Avatar asked Oct 18 '22 11:10

itzikos


1 Answers

You can create a symbolic link that points to itself with ln -s :

$ ln -s testlink testlink

$ ll testlink
lrwxrwxrwx 1 me myGroup 4 19 avr.  11:22 testlink -> testlink

However another file with the same name must not exist beforehand :

$ touch testlink

$ln -s testlink testlink
ln: impossible de créer le lien symbolique « testlink »: File exists
like image 54
Aaron Avatar answered Oct 21 '22 07:10

Aaron