Linux/Basic commands/cp

cp[1] command is used for copying files and directories. It lacks progress bar indicator[2], but you can use progress -w command to display the percentage of copied data or use rsync[3] command.

Ansible also includes a cp module with limited scalability (>hundreds of files) [4]

Options edit

-a, --archive
-l, --link hard link files instead of copying

Activities edit

  1. Understand the differences between cp, scp and rsync: https://stackoverflow.com/questions/20244585/how-does-scp-differ-from-rsync
  2. Understand --sparse option and usage cases
  3. Learn how to not overwrite a file with -n, --no-clobber option[5] or using rsync -a -v --ignore-existing src dst

See also edit

  • rsync, advanced copy and synchronization tool including progress indicator
  • progress [6]: Linux tool to show progress for cp, mv, dd. See also: pv[7] (Pipe Viewer). Example: progress -m
  • scp, dd, mv
  1. http://man7.org/linux/man-pages/man1/cp.1.html
  2. https://unix.stackexchange.com/questions/65077/is-it-possible-to-see-cp-speed-and-percent-copied
  3. https://stackoverflow.com/questions/6339287/copy-or-rsync-command
  4. https://docs.ansible.com/ansible/latest/modules/copy_module.html
  5. https://stackoverflow.com/questions/9392735/linux-how-to-copy-but-not-overwrite
  6. https://github.com/Xfennec/progress
  7. https://linux.die.net/man/1/pv