0

I'm experiencing very weird issue with moving and renaming directories and files using mv I have never experienced before. The weirdest thing is that it's happening on Ubuntu as well as on Cygwin on Windows.

mv attempts to create a hard link instead of actually moving or renaming a file or directory.

Example of renaming directory:

$ mkdir test
$ mv test test2
ln: ‘test’: hard link not allowed for directory

Example of renaming file:

$ touch test
$ mv test test2
$ ll -i
131140 -rw-rw-r-- 2 user group    0 Nov 13 16:06 test
131140 -rw-rw-r-- 2 user group    0 Nov 13 16:06 test2

It's evident that mv just created a hard link, because both files have the same inode number.

Why is it doing that?

I have also another system with Debian and mv is working as I expect there. Is it possible to configure this behavior somewhere in user's dotfiles? If I switch to root on Ubuntu, mv works fine. So I suspect some user's configuration, since I use the same dotfiles for Linux as well as for Cygwin.

  • 2
    What is the output of alias mv? – MariusMatutiae Nov 13 '14 at 17:16
  • Oh f***. I feel shame. It's an alias of ln -i. I have to find out what is doing that alias. Thank you. At least I know where to start. – David Ferenczy Rogožan Nov 13 '14 at 17:19
  • OK, solved. It was my fault. When I was creating "secure" aliases for cp, mv and ln with interactive argument I copy&pasted previous ones. And I have changed alias content but not alias name in case of ln alias. So it was mv='ln -i'. – David Ferenczy Rogožan Nov 13 '14 at 17:28
  • 1
    Always remember the type command: it's like which, except that it also includes aliases, functions, etc. Like which, there is also the -a option to show every possible interpretation. – AFH Nov 13 '14 at 17:58
  • Thank you. Actually I know it. But I didn't imagine that the cause could be on this level. I suspected something much more low-level, something on system level. Something like "system.filesystem.move_objects_this_way" or so :) – David Ferenczy Rogožan Nov 13 '14 at 18:02
1

So the cause was purely in me. I had this alias in my dotfiles which caused that weird behavior: alias mv='ln -i'.

Reason was simple: when I was creating "secured" aliases of cp, mv and ln using the interactive argument, I just copy&pasted previous aliases. And in case of an alias ln, I have changed content of the alias, but not its name. It should be ln='ln -i', but ended up in previously mentioned mv='ln -i'.

I feel shame. Sorry for stupid question, I doubt that someone will ever experience the same issue.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.