How to Copy Files and Directories in Linux (cp)

cp copies files or directories from a source path to a destination path.

Published September 29, 2026

cp copies files or directories from a source path to a destination path.

Key points

  • cp file1.txt file2.txt copies file1.txt to a new file named file2.txt
  • cp -r is required to copy an entire directory and its contents recursively
  • cp -i prompts for confirmation before overwriting an existing file at the destination

Example

cp -r ./src ./backup
More Linux articles