CentOS: Copy directory to another directory
LinuxCentosCopyCpLinux 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/