The cp command in Linux is used to copy files and directories from one location to another.
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.
Examples:
-
Copy a file:
cp file.txt /path/to/destination/This copies
file.txtto the specified destination directory. -
Copy a directory:
cp -r /source/directory /path/to/destination/This copies the entire directory and its contents.
-
Copy with prompt:
cp -i file.txt /path/to/destination/This will ask for confirmation before overwriting an existing file.
Let me know if you have more questions about the cp command or anything else!
