Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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...

share|improve this question
up vote 3 down vote accepted

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

share|improve this answer
    
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

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
share|improve this answer
cp -pRiv /var/www/{*,.*} /media/magneto

and, dovetailing off Thomas' answer:

pushd /var/www; cp -R . /media/magneto; popd;
share|improve this answer
    
Will this not ignore hidden files? – Jason May 4 '11 at 4:30
    
@Jason - There ya go. That should do it -- at least, it will work in bash, csh, and tcsh. – Brian Vandenberg May 4 '11 at 4:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .