What is the most accurate way to copy a file or a folder from one linux machine to another using commands?

closed as too broad by Romeo Ninov, Jesse_b, RalfFriedl, Thomas Dickey, mosvy Nov 15 '18 at 23:44

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.


There are various options like ftp, rsync etc. but the most useful of these is the scp which comes preinstalled with openssh package. Syntax is simple:

scp file.txt user@host:/folder/to/which/user/has/permissions

There are some other flags, for example, if you are using a different port other than 22 for ssh, you'd need to mention that in the command with -P option.

scp -P PORT file.txt user@host:/folder/to/which/user/has/permissions

For directories, it is advised to archive folder(s) in some container. The most easy is one is tar:

tar -cvf myfolder.tar folder1 folder2 folderN

And then use scp to send it across to another Linux machine (just replace file.txt with myfolder.tar).


rsync -a should be as accurate as accuracy can get.  -a stands for the archive mode.  A good description is given in its man page:

    rsync -avz foo:src/bar /data/tmp

This would recursively transfer all files from the directory src/bar on the machine foo into the /data/tmp/bar directory on the local machine.  The files are transferred in "archive" mode, which ensures that symbolic links, devices, attributes, permissions, ownerships, etc. are preserved in the transfer.  Additionally, compression will be used to reduce the size of data portions of the transfer.

The compression flag is -z and -v switches verbosity on.  Study the man page to find out much more.

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