3

I want to copy all the folders and files in the /var/www/ directory to another directory /media/magneto/

How do I do this?

I tried this command

cp -pRiv /var/www/ /media/magneto/

that didn't work because it basically created a directory called www underneath magento and started copying...

studiohack
  • 13,490
Jason
  • 1,899
  • 7
  • 31
  • 40

4 Answers4

3

Try

cp -R /var/www /media/magneto Avoid the extra forward slash at the end of the path name.

Or

you can navigate to the /var directory in terminal and then try

cp -R www /media/magneto

Thomas
  • 2,480
  • This did not work for me. It still copied over the "www" folder. I followed the last example, and even left off trailing slashes – Nick Rolando Aug 13 '15 at 20:05
2

If the magneto directory exists, you can use the following command:

cp -R /var/www /media/magneto

If it doesn't already exist you can use the following command to create it:

rsync -av /var/www/ /media/magneto
Gareth
  • 18,809
1
cp -pRiv /var/www/{*,.*} /media/magneto

and, dovetailing off Thomas' answer:

pushd /var/www; cp -R . /media/magneto; popd;
0
cp -R /var/www /media/magneto

This will copy www folder to /media/magneto folder
Use below cmd:

cp -R /var/www/* /media/magneto

This will copy all the files and folder to /media/magneto folder from www folder

Glorfindel
  • 4,099