Skip to content

Linux cp Guide

Mattscreative edited this page Nov 20, 2025 · 2 revisions

📋 Linux cp Guide

Complete beginner-friendly guide to cp on Linux, covering Arch Linux, CachyOS, and other distributions including copying files, directories, and backup operations.


📋 Table of Contents

  1. Understanding cp
  2. cp Basics
  3. Copying Files
  4. Copying Directories
  5. Troubleshooting

🎯 Understanding cp

What is cp?

cp (copy) copies files and directories.

Uses:

  • Copy files: Duplicate files
  • Backup: Create backups
  • Duplicate: Make copies
  • File management: Manage files

Why it matters:

  • Backup: Create file backups
  • Duplication: Copy files
  • Organization: Organize files

📋 cp Basics

Copy File

Basic usage:

# Copy file
cp source.txt destination.txt

# Copy to directory
cp file.txt /path/to/directory/

Multiple Files

Copy several:

# Copy multiple files
cp file1.txt file2.txt file3.txt /destination/

# All copied to destination

📄 Copying Files

Preserve Attributes

Keep properties:

# Preserve attributes
cp -p source.txt dest.txt

# Keeps:
# - Permissions
# - Timestamps
# - Ownership

Interactive Mode

Confirm overwrite:

# Interactive mode
cp -i source.txt dest.txt

# Asks before overwriting

📁 Copying Directories

Recursive Copy

Copy directory:

# Copy directory
cp -r source/ destination/

# Recursive copy

Preserve Structure

Keep structure:

# Preserve all
cp -a source/ destination/

# -a = archive mode
# Preserves everything

🔧 Troubleshooting

Permission Denied

Fix permissions:

# Check permissions
ls -l source.txt

# Use sudo if needed
sudo cp source.txt /destination/

📝 Summary

This guide covered cp usage, file/directory copying, and backup operations for Arch Linux, CachyOS, and other distributions.


🔗 Next Steps


This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.

Clone this wiki locally