The cp
command is used to copy files and directories in Unix and Unix-like operating systems.
cp [OPTION]... SOURCE... DIRECTORY
-a, --archive
: Copy directories recursively, preserving attributes.-i, --interactive
: Prompt before overwrite.-r, --recursive
: Copy directories recursively.-u, --update
: Copy only when the SOURCE file is newer than the destination file or when the destination file is missing.-v, --verbose
: Explain what is being done.Copy a file to another directory:
cp file.txt /path/to/destination/
Copy multiple files to another directory:
cp file1.txt file2.txt /path/to/destination/
Copy a directory and its contents:
cp -r /path/to/source_directory /path/to/destination_directory
Copy a file and prompt before overwrite:
cp -i file.txt /path/to/destination/