Transferring Files with Terminal

Using SCP and Rsync

You can use the terminal commands scp and rsync to move data between your local machine and the Mill.

SCP

scp is the underlying program behind the graphical scp tools WinSCP and Filezilla. You can use scp from the command line without these tools. The general syntax is:

scp (-r) user@source_host:/path/to/file user@destination_host:path/to/file

the -r flag is needed to recursively copy the contents of a folder. It is not needed if the target is a single file. Also, if the username@hostname is left blank, it is assumed to be the local computer. So in practice, usually only one user@hostname is specified. Example for the Mill:

#Transfer to the Mill
scp ~/file1 bbkbk@mill.mst.edu:~/file1

#Transfer from the Mill
scp bbkbk@mill.mst.edu:~/file1 ~/file1

Remember that the local computer is relative to the terminal: If your terminal is logged in to the Mill via ssh, then the Mill will be the local computer for that terminal.

Rsync

rsync is a powerful tool that extends and automates certain scp tasks. Instead of transferring files, rsync is used to sync a local and remote directory so that their contents are the same. This can move many files at once, but it also has the potential to delete files. Use with caution.

#Always do a dry run first to verify actions will be what you expect
rsync -avh --dry-run ~/phd_project/Simulation1/ bbkbk@mill.mst.edu:~/Simulation1/

#Sync to the Mill
rsync -avhz ~/phd_project/Simulation1/ bbkbk@mill.mst.edu:~/Simulation1/

#Sync From the Mill
rsync -avhz bbkbk@mill.mst.edu:~/Simulation1/ ~/phd_project/Simulation1/