LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-22-2002, 05:36 PM   #1
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
copying over a symlink


does anyone else think that the logic behind this is a bit odd?
Code:
root@trevor root]# ln -s target link
[root@trevor root]# ls -l target link
ls: target: No such file or directory
   0 lrwxrwxrwx    1 root     root            6 Sep 22 23:31 link -> target
[root@trevor root]# cp arealfile link 
cp: overwrite `link'? y
[root@trevor root]# ls -l target link
   0 lrwxrwxrwx    1 root     root            6 Sep 22 23:31 link -> target
4.0K -rw-r--r--    1 root     root          632 Sep 22 23:32 target
now i can see the logic in say, an redirection into a symlink being transferred over to the target file, but surely if you replace a symlink with a file, then that's what should happen. or do other people think it's logical?
 
Old 09-22-2002, 05:46 PM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 271Reputation: 271Reputation: 271
Like we were discussing online, I don't think its odd.

Cause when your copying a file to an existing link, its not overwriting the link but the file the link points to. The link is just the shortcut to the file.
 
Old 09-23-2002, 05:34 PM   #3
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu ; CentOS ; Raspbian
Posts: 12,613

Rep: Reputation: 69
I would think it's odd. I see the reasoning that Tricky has provided, but I would think that it would simply overwrite the symlink with the new file, not the linked file. But...

Since you are making a soft link, maybe that might explain it. What if you do the same thing using hard links?
 
Old 09-23-2002, 05:59 PM   #4
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 271Reputation: 271Reputation: 271
Bascially though any link copied over won't cause that is all a link is, it points to another file, etc. So when copying over to a symlink or a hardlink, all its going to do is say "hey, I'm gonna copy this to where I'm linking too, but won't let it copy over me cause all I am here to do is point you to my file I link to !"

Last edited by trickykid; 09-23-2002 at 06:00 PM.
 
Old 09-24-2002, 03:50 AM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Original Poster
Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
but if you delete a symlink, does it delete the file it points to instead?

NB. That is a RHETORICAL question... Just in case...

Last edited by acid_kewpie; 09-24-2002 at 09:16 AM.
 
Old 09-24-2002, 08:26 AM   #6
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 271Reputation: 271Reputation: 271
No. Cause your only removing the link that way. Same as if you delete the file and not the link, it just turns into a broken link.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Symlink Fredde87 Linux - General 14 09-30-2005 08:06 PM
where is symlink? guitarfella Slackware 3 12-04-2004 07:34 AM
symlink mikedelo Linux - Software 2 03-28-2004 12:32 PM
symlink evannextel Linux - Newbie 1 09-17-2003 03:54 PM
Symlink Mestax Linux - Newbie 3 09-04-2003 12:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:25 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
Open Source Consulting | Domain Registration