Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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 a directory from one place to another folder.

sudo cp is the command, but after that what should I type? The destination or source first?

share|improve this question
Does man cp help? – Portablejim Nov 17 '11 at 4:43

The -a flag is probably what you are looking for:

cp -a /path/from /path/to

The -a flag turns on recursive behaviour (which can also be done with the -R flag), and will also attempt to preserve metadata such as file ownership, permissions, timestamps, links, etc.

You should only need to use sudo if you are copying to a location not owned by the current user, if the current user doesn't have read permissions for the files being copied, or if you want to preserve ownership on files not owned by the current user.

share|improve this answer
in addition, as a rule of thumb, its always like that [command] [source] [destination]. This applies to mv, cp, ren. – Vineet Menon Nov 17 '11 at 5:19
@VineetMenon You probably mean mv, not ren. – jcollado Nov 17 '11 at 7:36
@jcollado:i have already added mv!! – Vineet Menon Nov 17 '11 at 8:49
@VineetMenon Yes, you're right, I didn't see that mv was already in the list. Anyway, my point was that, as far as I know, there isn't any ren command (unless you've got an alias or something set). – jcollado Nov 17 '11 at 9:28
@jcollado:haha...that was my alias for rename... :D – Vineet Menon Nov 17 '11 at 9:29

If you want to copy directory please use below command:

sudo cp -R Source_Folder Destination_Folder

This command can also be used to copy files, by just removing the "-R" which is used to copy the recursive structure of internal folders (if there are any in the Source_Folder path that we mentioned.)

One more example:

sudo cp -R /var/www/* /home/test_user/

Please feel free to leave a comment in case of any issue.

share|improve this answer

I think the better way is to use gksu nautilus command and you can copy whatever you want with common GUI as usual.

share|improve this answer
That assumes you are using a GUI and not CLI. – Phill Healey Jul 8 at 14:31

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.