Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
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?
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 !"
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.