Maintain monitoring of symbolic web links?

I make use of symbolic web links on a regular basis, yet after relocating the initial documents, I misplace the symbolic link. I additionally make use of symbolic web links for tracking some documents in the very same directory site, yet once more, I shed track.

  • Exists any kind of means (tool/method) to track the symbolic link whatever adjustment I make? Is the hard link the only means for this?
  • Exists any kind of means to make the symbolic link in a loved one means to make sure that when I relocate the directory site which contains both the initial and also link, the link needs to function.
2019-05-05 05:05:57
Source Share
Answers: 2

Concering your 2nd inquiry, if you make the symlink making use of a loved one course and afterwards relocate the entire directory site framework, it still needs to function. Take into consideration the list below incurable session :

~$ mkdir test
~$ cd test/
~/test$ mkdir test2
~/test$ cd test2/
~/test/test2$ touch testfile; echo "hello, world" > testfile
~/test/test2$ cat testfile 
hello, world
~/test/test2$ cd ..
~/test$ ln -s ./test2/testfile testfileln
~/test$ ls -l
total 8
drwxr-xr-x 2 xxxx xxxx 4096 2010-09-09 09:18 test2
lrwxrwxrwx 1 xxxx xxxx   16 2010-09-09 09:18 testfileln -> ./test2/testfile
~/test$ cd ..
~$ mv test/ testfoo
~$ cd testfoo/
~/testfoo$ ls -l
total 8
drwxr-xr-x 2 xxxx xxxx 4096 2010-09-09 09:18 test2
lrwxrwxrwx 1 xxxx xxxx   16 2010-09-09 09:18 testfileln -> ./test2/testfile
/testfoo$ cat testfileln 
hello, world

When it comes to your first inquiry, if you actually desire a link that will certainly describe the very same documents whatever you perform with the initial area of the documents, a hard link is possibly what you desire. A hard link is primarily simply an additional name describing the very same inode. Hence, there is no distinction in between the hard link and also the "initial documents." Nonetheless, if you require to link throughout documents systems, hard web links usually do not function and also you generally can not make tough web links to directory sites. Better, you will certainly see some distinctions when executing some documents procedures. Most especially, getting rid of the initial will certainly not remove the documents. The hard link will certainly still indicate the documents and also come.

2019-05-08 07:33:45

You can make use of the readlink command to discover/check what a (currently damaged) link initially indicated and afterwards repair it approximately indicate whatever the documents's new name/location is. Or you can do your documents relabeling just via a covering manuscript that relabels a documents and also look for and also solutions any kind of web links that indicate it. Regardless, you would certainly so something similar to this :

find . -type l | while read L
    if readlink $L | grep -q "^$OLDNAME\$"
        ln -sf $NEWNAME $L

Nonetheless, if you're doing this regularly after that symlinks are possibly not what you need to be making use of.

2019-05-08 06:30:52