Copy A Folder To A New Location Via The Terminal On Ubuntu
Using the terminal on a Ubuntu machine, how do you copy a directory and its contents to a new location?
You can do this using the
cp command native to Ubuntu, which is specifically intended for copying files and directories from one location to another.
Here's what the command in your terminal would look like:
cp -a /source/. /destination/
This command will recursively copy all the subdirectories and files in the
/source directory and copy them to a new location inside the
/destination directory doesn't already exist, a new directory with that name will be created before the contents are copied into it.
-a option preserves all the specified attributes for the files and subdirectories inside the
/source folder, including file attributes, timestamps, symlinks, ownership, mode, context, xattr, etc.
. at the end of the path to the
/source directory is a specific
cp syntax that allows the copying of all files and folders, including anything that is hidden.
For more information on the
cp command and its additional options, check out the Ubuntu manual pages.
Thanks for reading and happy computing!