terminal.cab

All commands

cp

Topic: Files and folders

Program: cp

Copies files and directories.

Package: core-files

Usage

cp [OPTION]... SOURCE... DEST

Description

Make DEST a copy of SOURCE. If DEST is a directory, put a copy of every SOURCE into it. Directories only with -r.

Options in the simulator

28 more options of the real program, not in the simulator yet
  • -a, --archive not in the simulator yet

    Explanation to come

  • --attributes-only not in the simulator yet

    Explanation to come

  • --backup value optional not in the simulator yet

    Explanation to come

  • -b not in the simulator yet

    Explanation to come

  • --copy-contents not in the simulator yet

    Explanation to come

  • -d not in the simulator yet

    Explanation to come

  • --debug not in the simulator yet

    Explanation to come

  • -H not in the simulator yet

    Explanation to come

  • -l, --link not in the simulator yet

    Explanation to come

  • -L, --dereference not in the simulator yet

    Explanation to come

  • -P, --no-dereference not in the simulator yet

    Explanation to come

  • --no-preserve needs a value not in the simulator yet

    Explanation to come

  • --parents not in the simulator yet

    Explanation to come

  • --reflink value optional not in the simulator yet

    Explanation to come

  • --remove-destination not in the simulator yet

    Explanation to come

  • --sparse needs a value not in the simulator yet

    Explanation to come

  • --strip-trailing-slashes not in the simulator yet

    Explanation to come

  • -s, --symbolic-link not in the simulator yet

    Explanation to come

  • -S, --suffix needs a value not in the simulator yet

    Explanation to come

  • -t, --target-directory needs a value not in the simulator yet

    Explanation to come

  • -T, --no-target-directory not in the simulator yet

    Explanation to come

  • --update value optional not in the simulator yet

    Explanation to come

  • -u not in the simulator yet

    Explanation to come

  • --keep-directory-symlink not in the simulator yet

    Explanation to come

  • -x, --one-file-system not in the simulator yet

    Explanation to come

  • -Z not in the simulator yet

    Explanation to come

  • --context value optional not in the simulator yet

    Explanation to come

  • --version not in the simulator yet

    On a real system it prints the version of the program.

Examples

From the lesson Copying, moving and renaming
cp notes.txt Documents/notes-copy.txt
ls Documents
'Holiday 2027.txt'   letter.txt   notes-copy.txt   notes.txt   recipes.txt

Try it in the terminal

From the lesson Copying, moving and renaming
cp -r projects/website projects/website-backup
ls projects
website  website-backup

Try it in the terminal

From the lesson Create, copy, move
cp notes.txt notes.txt.bak
cp -r projects/shop shop.bak
ls shop.bak
README.md  app.conf  build.log  releases  test.log
cp -p notes.txt keep.txt
ls -l notes.txt keep.txt
-rw-r--r-- 1 lerner lerner 76 Oct 17 08:15 keep.txt
-rw-r--r-- 1 lerner lerner 76 Oct 17 08:15 notes.txt

Try it in the terminal

From the command of the day: cp -i
cp -i todo.txt Documents/notes.txt
cp: overwrite 'Documents/notes.txt'? n
head -n 1 Documents/notes.txt
Buy milk

Try it in the terminal

Where you learn it

Lessons

Command of the day

All commands