• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

cp: command not found

by admin

The cp command enables you to copy and then paste a file or directory. The initial object is left where it is, but an exact duplicate of that object is created at the destination you specify. When you copy directories, you must specify the -R option to copy the specified directory recursively.

Syntax

The syntax of the cp command is:

$ cp [options] {file/directory name to copy} {file/directory name destination}

For example, to copy the ~/myfiles directory and its contents to /opt/myfiles:

$ cp -R ~/myfiles /opt/myfiles

If you encounter below error while running the cp command:

cp: command not found

you may try installing the below package as per your choice of distribution:

Distribution Command
OS X brew install coreutils
Debian apt-get install coreutils
Ubuntu apt-get install coreutils
Alpine apk add coreutils
Arch Linux pacman -S coreutils
Kali Linux apt-get install coreutils
CentOS yum install coreutils
Fedora dnf install coreutils
Raspbian apt-get install coreutils

cp Command Examples

1. Copy a file to another location:

$ cp path/to/source_file.ext path/to/target_file.ext

2. Copy a file into another directory, keeping the filename:

$ cp path/to/source_file.ext path/to/target_parent_directory

3. Recursively copy a directory’s contents to another location (if the destination exists, the directory is copied inside it):

$ cp -R path/to/source_directory path/to/target_directory

4. Copy a directory recursively, in verbose mode (shows files as they are copied):

$ cp -vR path/to/source_directory path/to/target_directory

5. Copy text files to another location, in interactive mode (prompts user before overwriting):

$ cp -i *.txt path/to/target_directory

6. Follow symbolic links before copying:

$ cp -L link path/to/target_directory

Conclusion

cp is the copy command included in the GNU coreutils package, which is installed by default on nearly every Linux distribution. cp is for simple copying. It may be all you need to maintain regular backups.

Filed Under: Linux

Some more articles you might also be interested in …

  1. mdadm Command Examples in Linux
  2. kdig Command Examples
  3. arduino-builder: A command-line tool for compiling arduino sketches
  4. mke2fs Command Examples in Linux
  5. getopt Command Examples in Linux
  6. googler Command Examples
  7. hlint: command not found
  8. grub-script-check: command not found
  9. eget: Easily install prebuilt binaries from GitHub
  10. csv-diff: View differences between two CSV, TSV or JSON files

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright