copy a folder

Copy a folder with everything inside it, keeping its dates and permissions if needed.

  • files

Steps

  1. cp -r src dest

    copy src and everything in it to dest

  2. cp -a src dest

    the same, keeping permissions, dates and links

  3. rsync -a src/ dest/

    copy what is inside src into dest; again later copies only what changed

  4. rsync -a --progress src/ dest/

    with progress, for big copies

Notes

  • With rsync the slash matters: src/ copies what is inside, src makes dest/src.

Commands used

  • cp
  • rsync

Each has a page in lore: lore cp opens it.