What happens if the Linux mv command is interrupted? Say, I'm moving a whole directory to some other place and interrupt it while it's moving. Will the source directory still be untouched?

7 Answers 7


If you move a directory on the same file system, you only move the directory entry from one location in the file system to another one.  E.g., mv /source/dir /target/dir will delete the directory entry of dir from /source and create a new one in /target. That's done by one atomic system call (i.e., uninterruptable). The inode containing the directory entries of dir as well as the actual content of the directory itself is not affected.

If you move the directory from one file system to another, all of the files are first copied to the new file system and then unlinked from the original one. So if you interrupt mv while it’s copying, you may end up with two copies of some of the files – at the old location and at the new one.

  • 7
    @Wesley: No, there will be no partial file. If the system stays up (e.g., you hit ctrl-C), it will be removed automatically. If not (e.g., power loss), the partial file may be left somewhere inaccessible on the destination disk, but should be cleaned up by the next fsck (which will most likely run automatically on reboot, since the disk wasn't unmounted cleanly). Mar 18, 2011 at 12:42
  • 67
    Wrong. If you move dir from one fs to another mv /fs1/dir /fs2/ and you interrupt, /fs1/dir/ will stay here completely. /fs1/dir is removed only when the move is complete.
    – user263131
    Oct 13, 2013 at 9:30
  • 14
    user263131 is right. Run strace mv /fs1/dir /fs2/ - the very last thing mv does is calling unlinkat on all source files at once (not one by one as they are copied).
    – Jakob
    Jul 5, 2014 at 9:58
  • 8
    @J.J Looks like that's because you used a bash expansion, in which case mv treats each file in the expansion as a separate source (thus doing them individually).
    – gkanwar
    Sep 9, 2016 at 17:52
  • 7
    So.... @bmk or others, do you want to update this answer to be less... wrong? Feb 5, 2018 at 0:15

The GNU implementation iterates over the arguments on the command line, attempts to rename first, and, if that fails, recursively copies and then recursively deletes the source. So

mv a b c/

will delete a before copying b, and will not start deleting anything in a before the destination copy is complete.

Note that this applies to the GNU implementation only.

To clarify: if a is a directory containing d and e, and b is a file, the order will be

  • create c/a
  • copy a/d -> c/a/d
  • copy a/e -> c/a/e
  • delete a/d
  • delete a/e
  • delete a
  • copy b -> c/b
  • delete b
  • 1
    Can you provide a source for this? Other answerers are saying a source file is deleted immediately after it is copied to a different fs (i.e. not all copied then all deleted).
    – jamesbtate
    Mar 18, 2011 at 18:02
  • 1
    Experience. I've added an example to make it more clear how my answer and the others are consistent. If you only list individual files then indeed each file will be deleted immediately. Mar 18, 2011 at 18:08
  • 1
    I observe the behaviour described in this answer on macOS, that is, with a BSD mv as well, so it is not GNU-only.
    – kirelagin
    Aug 21, 2019 at 7:55

You move one directory, interrupt the move, and the original directory will stay intact:

$ mv a b/

If you move multiple directories, each one will be intact on either the source or destination, depending on when you interrupted:

$ mv a b c/

How I got my answer:

$ mv --version
mv (GNU coreutils) 8.21

$ info mv
... It first uses some of the same code that's used by `cp -a'
to copy the requested directories and files, then (assuming the copy
succeeded) it removes the originals.  If the copy fails, then the part
that was copied to the destination partition is removed.  If you were
to copy three directories from one partition to another and the copy of
the first directory succeeded, but the second didn't, the first would
be left on the destination partition and the second and third would be
left on the original partition.

As a test, I copied a large folder to an NFS directory, interrupted, and the number of files in my source large folder stayed the same, and partial contents were left on the NFS directory. I used "find . -type f | wc -l" to verify.

Looks like Simon's answer is correct.


The accepted answer is definitely wrong about moving between file systems - a fact that saved me a lot of trouble a couple of times already. When moving a directory that containes subdirectories, no file in a subdirectory will be deleted before the whole subdirectory has been copied. This is, btw.the actual meaning of "object by object" - a subdirectory IS an object (file) and thus its integrity has to be preserved by a complete copy at the destination before anything can be deleted. So Simon's answer appears to me as the correct one.


If you want to interrupt mv because you want to disconnect from the terminal, you can just send it to background:

* press Ctrl+Z

# bg
# disown
  • 1
    That is a good point but it doesn`t answer the actual question. May 28, 2016 at 18:53
  • 3
    @JuliePelletier, but that's what I was searching for so someone may be interested in doing this. Jun 23, 2016 at 13:29

No. mv operates object by object, so objects that have already been processed will be removed from the source.


Definitely no. The move is made object by object. Hence, the object moved to the destination up to the point of interrupt shall not exist in the source any more.

If mv was issued for a large file (between different) and it has been interrupted then the source will be intact. On the target you will see an incomplete file up to the point of interruption.

You can however restore the mv with the same command and the process will continue.

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.