Вы находитесь на странице: 1из 4

5/6/2019 linux - CentOS: Copy directory to another directory - Stack Overflow

CentOS: Copy directory to another Ask Question

directory

I'm working with a


CentOS server. I have
36 a folder named test
located in
/home/server/folder/t
est . I need to copy
the directory test to
5 /home/server/ . How
can I do it?

linux centos copy

cp

edited Sep 26 '16 at 10:02


deltaag
153 1 7

asked Jan 27 '13 at 17:20


BaTmaN
350 2 7 15

5 Answers

cp -r /home/server/fol

65
answered Jan 27 '13 at 17:21
James McLaughlin
16.8k 39 51

By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our
2 if i need to copy
Terms of Service. Only all files in

https://stackoverflow.com/questions/14549967/centos-copy-directory-to-another-directory 1/4
5/6/2019 linux - CentOS: Copy directory to another directory - Stack Overflow
test
directory(without
test directory) to
/home/server/ .
how to ? –
BaTmaN Jan 27
'13 at 18:06

13 cp -r
/home/server/fold
er/test/*
/home/server/ –
James McLaughlin
Jan 27 '13 at 18:27

is there any
difference in using -
R in here ? –
mahen3d Jun 1 '15
at 5:32

If there's a directory
inside test
directory, yes there
is a difference. –
John Smith Feb 1
'17 at 4:11

To copy all files,


including hidden files
15 use:

cp -r /home/server/fol

edited Feb 3 '16 at 16:56


undone
7,116 4 36 65

answered Sep 26 '14 at 8:41


deltaag
153 1 7

3
Thanks for this.
Copying files no
By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our
problem, copying
Terms of Service. files and hidden files

https://stackoverflow.com/questions/14549967/centos-copy-directory-to-another-directory 2/4
5/6/2019 linux - CentOS: Copy directory to another directory - Stack Overflow

was an elusive
problem. +1 – Nate
Sep 4 '15 at 23:17

1 This is the only way


thats working for me.
The * doesn't work! –
user2924019 Feb 8
'17 at 20:06

1 this one works for


me! –
Hanny Setiawan
Dec 13 '17 at 4:20

In my case, in order
to save time, I
specify the current
directory like this: $
cp -r ./Origin/.
./Destination/ –
Pathros Mar 13 at
23:07

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

This can be done as:

-cp -rf /home/server/f

Hope this helps

edited May 14 '13 at 20:10


jmingov
8,125 2 25 32

answered May 14 '13 at 19:45


Rajeshwari
141 1 4

Doesn't work for me.


"No such file or
directory" when
adding the * . –
user2924019 Feb 8
'17 at 20:05

By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our
Terms of Service.

https://stackoverflow.com/questions/14549967/centos-copy-directory-to-another-directory 3/4
5/6/2019 linux - CentOS: Copy directory to another directory - Stack Overflow

This works for me.

cp -r /home/server/fol

1
edited Feb 5 at 4:34

answered Nov 29 '17 at 15:42


Hiren Parghi
712 7 22

For copy directory use


following command
0
cp -r source Destin

For example

cp -r /home/hasan /

For copy file use


command without -r

cp /home/file /ho

answered Nov 29 '17 at 17:22


Hasan Barary
402 2 6

By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our
Terms of Service.

https://stackoverflow.com/questions/14549967/centos-copy-directory-to-another-directory 4/4

Вам также может понравиться