cp - Copy Files in Linux

From the Linux Essential Commands cheat sheet · File & Directory Operations · verified Jul 2026

cp - Copy Files

Copy files and directories with options for recursive and interactive copying

bash
# Copy files
cp source.txt destination.txt
cp file1.txt file2.txt /target/dir/

# Copy directories (recursive)
cp -r source_dir/ dest_dir/

# Copy with confirmation
cp -i source.txt dest.txt

# Preserve attributes
cp -p file.txt backup.txt
✅ -r (recursive) is required for copying directories
💡 -i prompts before overwriting existing files
🔍 -p preserves timestamps, ownership, and permissions
filescopybasic

More Linux tasks

Back to the full Linux Essential Commands cheat sheet