Copying and moving files

Linux Command Line Quick Reference

1 min read

Published Aug 18 2026


19
0
0
0

CLILinuxUbuntu

cp copies files and directories. mv moves a path, and is also how files and directories are renamed.

Copy, move and rename

bash
cp source.txt copy.txtcp source.txt /path/to/directory/cp -r source-directory/ destination/cp -a source/ backup/cp -i source.txt destination.txtmv old.txt new.txtmv file.txt /path/to/directory/mv -i source destination

For cp, -r recursively copies a directory. -a is archive mode, preserving attributes such as permissions, timestamps and symbolic links while copying recursively. -i asks before overwriting an existing destination. -n avoids overwriting existing files.

For mv, moving within the same filesystem normally changes directory metadata rather than copying the file contents. Across filesystems it must copy the data and remove the source. -i asks before overwriting and -n prevents overwrites.

© 2025 SimpleSteps.guide
AboutFAQPoliciesContact
Linux Command Line Quick Reference | Copying and moving files | SimpleSteps.guide