
You can move and copy files locally or remotely using the mv, cp, and scp command-line tools.
To move files or folders from one location to another on the same computer, use the mv tool. The mv tool moves the file or folder from its old location and puts it in the new location.
For example, to move a file from your Downloads folder to a Work folder in your Documents folder:
mv ~/Downloads/MyFile.txt ~/Documents/Work/MyFile.txtYou can also change the name of the file as it’s moved:
mv ~/Downloads/MyFile.txt ~/Documents/Work/NewFileName.txtFor more information about the mv tool, see its man page.
To make a copy of a file, use the cp tool.
For example, to copy a folder named “Expenses” in your Documents folder to another volume named “Data”:
cp -R ~/Documents/Expenses /Volumes/Data/Expenses
The -R flag causes cp to copy the folder and its contents. Note that the folder name does not end with a slash, which would change how cp copies the folder.
For more information about the cp tool, see its man page.
To copy a file or folder to or from a remote computer, use the scp tool.
scp uses the same underlying protocols as ssh.
For example, to copy a compressed file from your home folder to the another user’s home folder on a remote server:
scp -E ~/ImportantPapers.tgz username@remoteserver.com:/Users/username/Desktop/ImportantPapers.tgz
You’re prompted for the user’s password.
The -E flag preserves extended attributes, resource forks, and ACL information.
The -r flag, which isn’t used in this example, causes scp to copy a folder and its contents.
For more information about the scp tool, see its man page.