Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

3 Answers

up vote 1 down vote accepted


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


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

cp -R www /media/magneto

share|improve this answer
add comment

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
add comment
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
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.