# Let's look at a few pathologies surrounding symlinks. set -x touch file # just an empty file ln -s file link # and an innocent symlink rm file # get rid of ‹file›, leaving the link behind ln -s dangling badlink # we can directly create a dangling link ls -l link badlink # what does ‹ls› say about those? cat badlink # fails, no such file... ln -s badlink dangling # let's make a loop just for fun ls -l badlink dangling cat badlink # fails in a new and interesting way rm -d link dangling badlink # Here is another, slightly different pathology with loops: mkdir -p dir/subdir ln -s .. dir/subdir/link ls dir ls dir/subdir ls dir/subdir/link ls dir/subdir/link/subdir ls dir/subdir/link/subdir/link ls dir/subdir/link/subdir/link/subdir rm -r dir # eww, go away ugly thing # Let's move on to the C view of things, in ‹links.c›.