How to Copy the Contents of a Folder to Another Folder from Terminal in Ubuntu
Topic: Ubuntu / LinuxPrev|Next
Answer: Use the
You can use the
cp command to copy files locally from one directory to another.
For instance, if you want to copy the contents of the
source folder to the
destination folder in your current working directory, you can use the following command:
-a option copy files recursively, while preserving the file attributes such as timestamp. The period symbol (
.) at end of the source path allows to copy all files and folders, including hidden ones.
For example, if your current working directory is
/var/www and you want to copy the contents of the
assets folder to
backup folder, you can simply use the command:
Alternatively, you can provide absolute path like this:
Both commands will have the same effect, because current working directory doesn't matter when you use absolute path. Any path that starts with a forward slash
/ is an absolute path.
Here are some more FAQ related to this topic:
- How to change current working directory in Ubuntu terminal
- How to unzip a zip file from the terminal in Ubuntu
- How to delete a non empty directory from terminal in Ubuntu