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.

5
  • 2
    What is the output of alias mv? Nov 13, 2014 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. Nov 13, 2014 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'. Nov 13, 2014 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, 2014 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 :) Nov 13, 2014 at 18:02

1 Answer 1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .