cp

Linux · Files · available in the simulator

What it does

Copy files and directories. Wildcards: * (any number of characters), ? (0 or 1 character).

Syntax

cp [opciones] origen... destino

Options and parameters

  • -R

    Copy directories recursively.

  • -i

    Prompt before overwrite.

  • -v

    Explain what is being done.

  • -p

    Preserve file attributes such as mode, ownership, and timestamps.

  • -f

    Force copy by removing existing destination files if necessary.

  • -r

    Copy directories recursively.

    cp -r carpeta/ copia/
  • -a

    Archive mode; copy recursively and preserve attributes, timestamps, and links.

    cp -a origen/ destino/
  • -n

    Do not overwrite an existing file.

  • -u

    Copy only when the source file is newer than the destination file.

  • -l

    Hard link files instead of copying.

  • -s

    Make symbolic links instead of copying.

Usage examples

  • cp error ..
  • cp -R sistemas backup
  • cp -i a.txt b.txt
  • cp archivo.txt copia.txt
  • cp -r src/ backup/
  • cp -r carpeta/ copia/
  • cp -a origen/ destino/
Practise cp

Related commands