What is the `cp` command?

QuestionsQuestions8 SkillsProBasic Files OperationsAug, 23 2025
0164

The cp command is a standard command in Linux used to copy files and directories from one location to another. It allows you to duplicate files or entire directories, making it a fundamental tool for file management in the Linux environment.

Basic Syntax

cp [options] source destination

Common Options

  • -r: Recursively copy directories and their contents.
  • -i: Prompt before overwriting files.
  • -u: Copy only when the source file is newer than the destination file or when the destination file is missing.
  • -v: Verbosely show the files being copied.

Example Usage

To copy a file:

cp file.txt /path/to/destination/

To copy a directory and its contents:

cp -r directory_name /path/to/destination/

The cp command is essential for tasks such as backing up data and organizing files within the file system.

0 Comments

no data
Be the first to share your comment!