The cp command
Copy files and directories. Copies SOURCE to DEST. If the last name is an existing directory, the copies go inside it and keep their names. Copying a directory needs -r. An existing file at DEST is overwritten without asking.
Usage
cp [OPTION]... SOURCE DEST cp [OPTION]... SOURCE... DIRECTORY
Options
| -r, -R, --recursive | copy directories and everything in them |
|---|---|
| -v, --verbose | say what was copied |
Examples
cp report.txt report-backup.txtA copy with a new namecp *.jpg photos/Copy several files into a foldercp -r website website-oldCopy a whole folder
Learn it step by step
Related commands
learner@sandbox: ~bash (practice)
Note: Try cp here: your home directory has sample files. Press Try beside an example, or type your own.
Enter runs · Tab completes names · ↑ ↓ step through history · Ctrl+L clears · type help for every command
A practice shell in your browser that behaves like bash on Linux for these commands. Nothing you type leaves the page.