usage of softlinks

usage of symbolic links

symbolic links also called soft links,soft links is means shortcut as windows,it has different inode as original file.
hard link like copy of a file,it has the same inode as original file.

ln -s targetffile/targetdir linkname

how to remove

  1. rm linkname
  2. unlink linkname

pay attention

if your softlink is point to a directory,when you delete your softlink,DON’T ADD “/” at the end of the link name,or it will delete all the files in the target directory.
for example:

mkdir dir
cd dir
touch a.a b.b c.c d.d
cd ..
ln -s dir mylink
unlink mylink    //it's ok,it will delete soft link,but won't delete the target dir
unlink mylink/    //it's ok,it will delete soft link,but won't delete the target dir
rm mylink       //it 's ok,it wi ll delete soft link,but won't delete the target dir
rm -r mylink   //it 's ok,it wi ll delete soft link,but won't delete the target dir
rm -rf mylink  //it 's ok,it wi ll delete soft link,but won't delete the target dir
rm -r mylink/   __*IT'S NOT OK,it will delete the target dir !!!*__

so ,for safe use, dont use “-r” option, dont’t add “/” at the end of linkname;
use “unlink” is better.

CONCLUSION:
DONT ADD “/” AT THE END OF LINKNAME.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章