Copying and moving files
Linux Command Line Quick Reference
1 min read
This section is 1 min read, full guide is 20 min read
Published Aug 18 2026
19
Show sections list
0
Log in to enable the "Like" button
0
Guide comments
0
Log in to enable the "Save" button
Respond to this guide
Guide Sections
Guide Comments
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 destinationFor 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.