Terminal Dojo
Help العربية Sign inGet started

Command library / cp

cp

BashDraft — pending expert review4 practice missions

Copy files and directories

Copies a file (or, with -r, an entire directory tree) to a new location. The source comes first, the destination second — get that backwards and you copy the wrong thing over the wrong thing.

Practice cp

Usage

cp [options] source destination

Options and flags

Examples

Common mistakes

cp -r project/ cp -r project/ project-backup/

cp needs both a source AND a destination — it never guesses where the copy should go.

cp project/ project-backup/ cp -r project/ project-backup/

Copying a directory without -r fails with 'omitting directory' — the recursive flag is required for folders.

Related commands

lschmod