Linux cp Command Builder (Copy Files & Directories)
The cp command is used to copy files and directories in Linux. This interactive cp Command Builder helps you generate precise copy commands with the right options for your use case.
🚀 What is the cp Command?
The cp command allows you to:
- Copy individual files
- Copy entire directory trees recursively
- Preserve file attributes (permissions, timestamps)
- Create backup copies before overwriting
- Make symbolic or hard links instead of copying
⚙️ Basic Syntax
cp [options] SOURCE DESTINATION
cp [options] SOURCE1 SOURCE2 ... DESTDIR🧠 How to Use This cp Command Builder
This tool helps you:
- Select source and destination paths
- Choose copy mode (recursive, preserve attributes, etc.)
- Handle existing files (overwrite, backup, skip)
- Generate a ready-to-use cp command
Workflow
- Specify source file(s) or directory
- Specify destination path
- Choose options (recursive for directories, preserve for attributes)
- Copy generated command
🔧 Common cp Usage Patterns
Copy a Single File
cp source.txt destination.txtCopy File to Directory
cp file.txt /path/to/directory/Copy Directory Recursively
cp -r source_dir/ dest_dir/Copy with Permissions Preserved
cp -p source.txt destination.txtCopy Everything with Archive Mode
cp -a source/ destination/Copy and Ask Before Overwriting
cp -i source.txt destination.txtCopy Without Overwriting Existing Files
cp -n source.txt destination.txt⚠️ Important Notes
- Recursive copying: Use
-ror-Rto copy directories - Preserve attributes: Use
-por-ato keep permissions and timestamps - Safety: Always use
-ito confirm before overwriting in production - Symlinks: By default, symlinks are followed. Use
-Pto copy the link itself