Files and folders

The cp command

Copies files. For whole folders it needs -r.

Syntax

cp [-r] <origen> <destino>

Most useful options

-rCopies folders and their content
-iAsks before overwriting
-uCopies only if the source is newer

Copy-ready examples

$ cp Documentos/apuntes.txt notas.txtCopy a file
$ cp -r Documentos copia-docsCopy a whole folder

You can try them in the browser terminal: it does not touch your computer.

Typical mistakes

  • If the destination exists, it overwrites it without asking.

Related commands

FAQ

Does it copy subfolders too?

Only with -r. Without it, it errors when it sees a folder.

Learn to actually use it

The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.

Start the free course