Home
Man
Search
Today's Posts
Register

This forum is closed for new posts. Please post beginner questions to learn unix and learn linux in the UNIX for Beginners Questions & Answers forum.

change target of a symbolic link

Tags
beginners, change, link, symbolic

 

 
Thread Tools Search this Thread
# 1  
Old 02-13-2008
change target of a symbolic link

Hi,

Is it possible to change the target of a symbolic link?

What I currently have is:
/home/Data1
/home/Data2
/home/Stores

In the Stores directory, I did: ln -s /home/Data1 /home/Stores/abc
$ pwd
/home/Stores
$ ls -latr
lrwxrwxrwx 1 dandy dandy 46 Feb 12 16:38 abc -> /home/Data1

I want to now change that target to:
abc -> /home/Data2

BUT, I don't want to do have to delete the link and re-create it to the new target. I just want to rename/change/modify the target. Is it possible?


Thanks
# 2  
Old 02-13-2008
Yes it is possible
# 3  
Old 09-22-2008
So how do you change the target of a symlink?
# 4  
Old 09-23-2008
Very interested to hear fpmurphy's explanation on how to change target of symlink without deleting the symlink first.

I normally delete the symlink and re-create it on one line, minimizing the time the link does not exist:

rm mysymlink ; ln -s mytargetfile mysymlink

I suppose you could write a little hack which does it in one go, but I've never heard of one which is included in standard POSIX systems...
# 5  
Old 09-23-2008
fpmurphy is absolutely correct...yes you can change the target of a soft link without deleting the old one by forcing ln to do so.
Code:
ln -s /home/Data1 /home/Stores/abc
ln -f -s /home/Data2 /home/Stores/abc

# 6  
Old 09-23-2008
wow, thanx
 

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Moving the target of a symbolic link ejianu Shell Programming and Scripting 4 04-07-2015 06:31 PM
awk symbolic link xpukm Shell Programming and Scripting 1 11-20-2013 07:01 PM
How to remove symbolic link? jediwannabe Red Hat 3 04-26-2013 11:19 AM
Symbolic link yifangt UNIX for Dummies Questions & Answers 4 02-06-2013 05:47 PM
Change reference of symbolic link sethmj Shell Programming and Scripting 2 01-14-2013 11:47 PM
[Solved] Symbolic link not allowed or link target not accessible newbielgn UNIX for Dummies Questions & Answers 0 09-04-2012 12:21 PM
ls on a symbolic link newbie_01 Shell Programming and Scripting 7 08-30-2012 10:17 AM
issue with Symbolic link kumarmani Solaris 4 12-28-2011 07:19 AM
Symbolic Link Help LAVco Shell Programming and Scripting 2 06-07-2010 04:15 PM
symbolic link tonijel Shell Programming and Scripting 2 10-01-2009 07:23 AM
ZIP a soft / symbolic link target galz UNIX for Dummies Questions & Answers 1 06-10-2008 05:36 AM
need some info about symbolic link and hard link detective linux UNIX for Dummies Questions & Answers 2 01-08-2008 07:36 AM
[help] about symbolic link solaris 8 bucci Solaris 1 10-12-2006 07:30 AM
Creating symbolic link charbel Shell Programming and Scripting 9 10-01-2006 12:46 PM
symbolic Link bhargav UNIX for Dummies Questions & Answers 1 10-15-2004 10:41 AM


All times are GMT -4. The time now is 08:28 AM.

Unix & Linux Forums Content Copyright 1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password