cp
Copy a file or a folder
What it does
cp copies a file: what first, then where. If the second argument is an existing folder, the copy goes into it under the same name; otherwise you get a file with the new name.
Folders are copied only with -r, recursively with everything inside. Without it cp refuses and says it is a directory.
Careful. If a file with that name exists, cp silently overwrites it. -i asks before overwriting.
Syntax
cp <file> <destination>
cp -r <folder> <destination>Examples
Copy config.json to config.backup.json
cp config.json config.backup.jsoncp— copyconfig.json— what to copyconfig.backup.json— where to
Copy the assets folder with everything in it to backup
cp -r assets backupsame as:
cp -R assets backup,cp --recursive assets backupcp— copy-r— recursively, with contentsassets backup— from → to