54

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?

deltaag
  • 363
  • 3
  • 7
BaTmaN
  • 825
  • 2
  • 11
  • 16

5 Answers5

106
cp -r /home/server/folder/test /home/server/
James M
  • 18,506
  • 3
  • 48
  • 56
26

To copy all files, including hidden files use:

cp -r /home/server/folder/test/. /home/server/
undone
  • 7,857
  • 4
  • 44
  • 69
deltaag
  • 363
  • 3
  • 7
17

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

jmingov
  • 13,553
  • 2
  • 34
  • 37
Rajeshwari
  • 171
  • 1
  • 4
2

This works for me.

cp -r /home/server/folder/test/. /home/server
Hiren Parghi
  • 1,795
  • 1
  • 21
  • 30
1

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/
Hasan Barary
  • 812
  • 8
  • 8