Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know that using scp over SSH will copy the files between hosts, but what if I don't want to copy them but instead move them over entirely?

What command could I use using a secure connection over SSH or otherwise?


share|improve this question
up vote 2 down vote accepted

There is no such thing as "move".

On a single filesystem, you can "move" a file by renaming it; the file itself stays in place, but a new name gets added and an old one removed (this is not guaranteed to be atomic, either - if both "a" and "b" exists, then calling mv a b may very briefly have both names refer to the same file "a", before that old name goes away).

To move a file from one place to another in the general case, you need to create a file with the new name, copy the data into it, and then delete the old one. On a local machine, but different filesystems, the "mv" command does that for you behind the scenes - you can see this happen this by running strace mv a /other/filesystem/b.

To do this between computers without a shared network filesystem, you have to do it step by step yourself, e.g. scp a otherhost:/path/to/new/a && rm a (the ampersands mean that the local file is only deleted if scp succeeded, which means it's extremely likely that the remote copy was made successfully).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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