Problem Statement
Which command copies files and directories recursively?
Explanation
The cp -r (or cp -R) command copies directories and their contents recursively, including all subdirectories and files. The -r flag stands for recursive and is necessary when copying directories since cp alone only copies files. Without -r, attempting to copy a directory results in an error.
Common cp options include -i for interactive mode (prompting before overwrite), -v for verbose output, -p to preserve file attributes (permissions, timestamps), and -a for archive mode (preserves everything and copies recursively). For example, cp -a source/ destination/ creates an exact copy.
Related commands include mv for moving/renaming files, rm for deletion, and rsync for more advanced copying with features like progress display, partial transfers, and network copying. Understanding cp is fundamental for file management in Linux.
