How do you copy a file in Linux?

Answer

Use the cp command. cp source destination copies a file. cp -r source_dir dest_dir copies a directory recursively. cp -p preserves file attributes (timestamps, permissions, ownership). cp -i prompts before overwriting. cp -u only copies if the source is newer than the destination. Example: cp -rp /etc/nginx /backup/nginx_backup copies the Nginx config directory preserving all attributes.