Mailinglist Archive: opensuse (3767 mails)
| < Previous | Next > |
Unexpected behaviour of cp -- writes to the *target* of a link
- From: Shriramana Sharma <samjnaa@xxxxxxxxx>
- Date: Sat, 18 Feb 2006 14:56:51 +0530
- Message-id: <200602181456.51945.samjnaa@xxxxxxxxx>
Observe the following:
~> mkdir a
~> mkdir b
~> touch a/hello
~> chmod 0444 a/hello
~> ls -l a/
total 0
-r--r--r-- 1 samjnaa users 0 2006-02-18 14:52 hello
~> cd b
~/b> ln -s ../a/hello
~/b> ls -l
total 0
lrwxrwxrwx 1 samjnaa users 10 2006-02-18 14:53 hello -> ../a/hello
~/b> ls -l > list
~/b> ls -l
total 4
lrwxrwxrwx 1 samjnaa users 10 2006-02-18 14:53 hello -> ../a/hello
-rw-r--r-- 1 samjnaa users 129 2006-02-18 14:53 list
~/b> cp list hello
cp: cannot create regular file `hello': Permission denied
~/b> sudo cp list hello
Password:
~/b> ls -l ~/a/
total 4
-r--r--r-- 1 samjnaa users 129 2006-02-18 14:53 hello
~/b>
What is surprising here is that while I expected the cp operation to replace
the link with the text file, it replaced the *target of the link*. Is this
expected behaviour? In Konqueror, if I try to copy a regular file to a
directory containing a symbolic link with the same name as the file, it asks
me if I want to overwrite and if I say yes it overwrites the link, not the
target of the link.
--
Tux #395953 resides at http://samvit.org
playing with KDE 3.51 on SUSE Linux 10.0
$ date [] CCE +2006-02-18 W07-6 UTC+0530
~> mkdir a
~> mkdir b
~> touch a/hello
~> chmod 0444 a/hello
~> ls -l a/
total 0
-r--r--r-- 1 samjnaa users 0 2006-02-18 14:52 hello
~> cd b
~/b> ln -s ../a/hello
~/b> ls -l
total 0
lrwxrwxrwx 1 samjnaa users 10 2006-02-18 14:53 hello -> ../a/hello
~/b> ls -l > list
~/b> ls -l
total 4
lrwxrwxrwx 1 samjnaa users 10 2006-02-18 14:53 hello -> ../a/hello
-rw-r--r-- 1 samjnaa users 129 2006-02-18 14:53 list
~/b> cp list hello
cp: cannot create regular file `hello': Permission denied
~/b> sudo cp list hello
Password:
~/b> ls -l ~/a/
total 4
-r--r--r-- 1 samjnaa users 129 2006-02-18 14:53 hello
~/b>
What is surprising here is that while I expected the cp operation to replace
the link with the text file, it replaced the *target of the link*. Is this
expected behaviour? In Konqueror, if I try to copy a regular file to a
directory containing a symbolic link with the same name as the file, it asks
me if I want to overwrite and if I say yes it overwrites the link, not the
target of the link.
--
Tux #395953 resides at http://samvit.org
playing with KDE 3.51 on SUSE Linux 10.0
$ date [] CCE +2006-02-18 W07-6 UTC+0530
| < Previous | Next > |