LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Breaking soft link temporarily (https://www.linuxquestions.org/questions/linux-newbie-8/breaking-soft-link-temporarily-923641/)

DirtyHowi 01-13-2012 02:19 PM

Breaking soft link temporarily
 
The only thing i have been able to find about breaking a soft link is to delete the target file, i need to break a link, test something, then put the link back.

will moving the target file to another folder/directory/whatever you call them in linux (i am a windows dev normally, please dont hate me) break the link then moving it back after i have completed testing and reestablishing the link work?

JimBrewster 01-13-2012 02:32 PM

Assuming you mean a symbolic link, or symlink. The link is just a pointer to the actual file.

Moving the original file will break the link. Moving it back will fix it.

Whether moving the link breaks it depends on whether it points to the absolute or relative path of the original file.

For example, if I create a symlink to file foo with an absolute path like this:
Code:

~$ ln -s /home/user/foo bar
bar will always point to foo wherever I move bar.

but if I do a relative path:
Code:

~$ ln -s foo bar
bar will only point to foo in the same directory.

If you delete the symlink, it is always easy enough to recreate it, so that is what is usually done.

DirtyHowi 01-13-2012 02:40 PM

currently the link looks like file->\companyname\test\bin\file1 where file 1 is a shell script that intercepts certain actions (there are three total i need to test), i need to keep that until go live, but also need to test it. i was going to create a dir under \companyname\test\bin\storage the mv file to there, test, then mv file back, if i understand you the simple act of moving the file back will restore the link??

JimBrewster 01-13-2012 02:58 PM

Don't forget forward-slash (/) is directory delimiter in Unix/Linux. Backslash (\) is DOS/Windows.

So anyway, yes that should work. The contents of the symlink is just the path to the target!


All times are GMT -5. The time now is 07:46 AM.