LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-13-2012, 02:19 PM   #1
DirtyHowi
Member
 
Registered: Jan 2012
Posts: 34

Rep: Reputation: Disabled
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?
 
Old 01-13-2012, 02:32 PM   #2
JimBrewster
Member
 
Registered: Feb 2010
Location: usa:/dev/random
Distribution: Slackware, Salix
Posts: 237

Rep: Reputation: 59
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.
 
Old 01-13-2012, 02:40 PM   #3
DirtyHowi
Member
 
Registered: Jan 2012
Posts: 34

Original Poster
Rep: Reputation: Disabled
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??
 
Old 01-13-2012, 02:58 PM   #4
JimBrewster
Member
 
Registered: Feb 2010
Location: usa:/dev/random
Distribution: Slackware, Salix
Posts: 237

Rep: Reputation: 59
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!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
D-Link DWA-130 - SIOCSIFFLAGS: Resource temporarily unavailable. XIII13 Linux - Networking 1 08-02-2014 06:12 PM
Difference Between Soft Link & Hard Link rajaniyer123 Solaris / OpenSolaris 16 09-30-2012 04:42 AM
create soft link and hard link in RHEL5 ramadas88 Linux - Server 6 09-15-2010 05:32 AM
hard link and soft link varunrapelly Linux - Newbie 9 10-02-2008 08:05 AM
Soft Link and Hard Link Moataz Red Hat 1 04-25-2005 07:30 AM


All times are GMT -5. The time now is 03:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration