4

Running the copy command as sudo cp -v -r -f source destination, for few directories and files, getting error as cp: cannot overwrite directory with non-directory.

1
  • The error message seems quite clear. Can you describe your problem in more detail?
    – Blackwood
    Jan 17 '19 at 16:44
5

CASE 1 You get this error when you try to copy a file (source) that has the same name of a directory (destination).

CASE 2 You get this error when you try to copy a symlink (source) in a directory (destination) where there is already an object with the same name.

SOLUTIONS

Use rsync. See also the following options about symlinks

-l, --links copy symlinks as symlinks

-L, --copy-links transform symlink into referent file/dir

--copy-unsafe-links only "unsafe" symlinks are transformed

--safe-links ignore symlinks that point outside the tree

-k, --copy-dirlinks transform symlink to dir into referent dir

-K, --keep-dirlinks treat symlinked dir on receiver as dir

Otherwise: manually remove the object from destination path (or move, or rename), then copy the object from the source path.

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.