How To Copy Files From One Directory To Another In Ubuntu
January 4, 2018
http://askubuntu.com/questions/80065/i-want-to-copy-a-directory-from-one-place-to-another-via-the-command-linehttp://askubuntu.com/questions/86822/how-can-i-copy-the-contents-of-a-folder-to-another-folder-in-a-different-directo
$ sudo cp -R Source_Folder Destination_Folderexample:$ sudo cp -R /media/mydrive/Movies /media/backupThis command can also be used to copy files, by just removing the “-R” which is used to copy the recursive structure of internal folders (if there are any in the Source_Folder path that we mentioned.)The -a flag turns on recursive behaviour (which can also be done with the -R flag), and will also attempt to preserve metadata such as file ownership, permissions, timestamps, links, etc.cp -a /source/. /dest/The -a option is an improved recursive option, that preserve all file attributes, and also preserve symlinks.The . at end of the source path is a specific cp syntax that allow to copy all files and folders, included hidden ones.An alternate is rsyncrsync -r source/ destinationThe advantages of rsync are:- After the initial sync, it will then copy only the files that have changed.
- You can use it over a network, convenient for files in $HOME, especially config files.
Posted in Tutorials