cp — copy files and directories
cheat sheet · Ubuntu 24.04 · GNU coreutils 9.4 https://lab.dimsanych.ru/en/wiki/cp/Cheat sheet
-
cp app.conf app.conf.baka copy next to it, another name -
cp app.conf /tmp/into a directory, same name -
cp a.txt b.txt docs/several files into a directory -
cp -r project project-copya whole directory -
cp -a /etc/nginx ~/nginx-backupkeep permissions, owner, times -
cp -i app.conf /etc/app.confask before overwriting -
cp -n app.conf /etc/app.confnever overwrite an existing file -
cp -u *.conf /srv/conf/only if the source is newer -
cp -v a.txt b.txtprint what gets copied -
cp -r project/. backup/a directory's contents, not itself
Options
cp and mv share many options: -i, -n, -u, -v, -b, -t. Full list —
man cp.