I have a folder I just luckily recovered sitting on:

/media/sdc1/Pictures

with a BUNCH of subdirectories and files that I need.

I want to copy these to a folder on:

/media/sdb1/Pictures

What command do I have to use in the terminal to make sure this happens? I know there is the cp command. But is that the best choice? And if so what options should I use to ensure I get every single directory and file?

up vote 17 down vote accepted

I would use rsync for this so that if there is an error (or you need to stop copying) partway through you can easily resume later, without having to recopy everything.

rsync -av /media/sdc1/Pictures/ /media/sdb1/Pictures/
  • 3
    I'd remove the * since it will omit dotfiles at the first level. It may also cause it to exceed the ARG_MAX limit. – geirha Jun 1 '13 at 9:31
  • @geirha good point. edited. – amc Jun 1 '13 at 18:09
  • great I will do this, thanks everyone – wardr Jun 1 '13 at 20:38

cp -r /media/sdc1/Pictures/* /media/sdb1/Pictures/some_dir

  • The -r is recursive, read the man page...
  • With /media/sdc1/Pictures/* the asterisk is to copy all the contents of /media/sdc1/Pictures/, but not the parent directory itself.
  • The some_dir of /media/sdb1/Pictures/some_dir is where you want to put it.
  • will this copy dotfiles and dotdirs as well? – farinspace Apr 28 at 5:52

If you need an exact image, use the command dd if=(path) of=(path)

  • 4
    Beware, this command could completely kill you computer if used incorrectly – MikeSchem Apr 10 '17 at 21:03
  • You can't copy directories with dd! – mook765 Aug 7 at 8:11

protected by Community Apr 28 at 16:01

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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