The GNU Coreutils manual for mv
says:
If a destination file exists but is normally unwritable, standard input is a terminal, and the -f or --force option is not given, mv prompts the user for whether to replace the file. (You might own the file, or have write permission on its directory.) If the response is not affirmative, the file is skipped.
However, the version of mv
I am using (GNU coreutils 8.21 on Ubuntu 14.04.3 LTS) exhibits unexpected behaviour:
$ which mv
/bin/mv
$ ls -l
total 0
$ echo foo > 1; chmod -w 1; cp 1 2; ls -l | cut -d' ' -f 1-5,9
-r-x------ 1 me me 4 1
-r-x------ 1 me me 4 2
$ echo bar > 2
-bash: 2: Permission denied
$ mv 1 2
$ ls -l | cut -d' ' -f 1-5,9
-r-x------ 1 me me 4 2
Based upon the manual excerpt quoted above, I would have expected the mv 1 2
command to have prompted the user before overwriting file 2
.
Is there a bug in my version of mv
, or a bug in my understanding? If the latter, then what does the manual mean?
ls -l /proc/self/fd/0
output?root
? Is the file writable to you by some other means like ACLs ([ -w 2 ] && echo yes
outputsyes
)?mv
? Are you sure you're running/bin/mv
?