CentOS: Copy directory to another directory

LinuxCentosCopyCp

Linux Problem Overview


I'm working with a CentOS server. I have a folder named test located in /home/server/folder/test. I need to copy the directory test to /home/server/. How can I do it?

Linux Solutions


Solution 1 - Linux

cp -r /home/server/folder/test /home/server/

Solution 2 - Linux

To copy all files, including hidden files use:

cp -r /home/server/folder/test/. /home/server/

Solution 3 - Linux

As I understand, you want to recursively copy test directory into /home/server/ path...

This can be done as:

-cp -rf /home/server/folder/test/* /home/server/

Hope this helps

Solution 4 - Linux

This works for me.

cp -r /home/server/folder/test/. /home/server

Solution 5 - Linux

For copy directory use following command

cp -r source    Destination

For example

cp -r  /home/hasan   /opt 

For copy file use command without -r

cp   /home/file    /home/hasan/

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBaTmaNView Question on Stackoverflow
Solution 1 - LinuxJames McLaughlinView Answer on Stackoverflow
Solution 2 - LinuxdeltaagView Answer on Stackoverflow
Solution 3 - LinuxRajeshwariView Answer on Stackoverflow
Solution 4 - LinuxHiren ParghiView Answer on Stackoverflow
Solution 5 - LinuxHasan BararyView Answer on Stackoverflow