Ad space (banner)
🖥️Linux Lessons
Lesson 12 / 61

Copying and Moving with cp / mv

cp and mv are for when "I want to copy a file, or move it somewhere else." cp makes a copy and leaves the original in place; mv moves (or renames) a file, so it's gone from its original spot.

Use them in the form cp source destination and mv source destination. To copy an entire folder, add the -r option to cp.

Running cp notes.txt notes-copy.txt creates a new notes-copy.txt holding the same content as notes.txt, while the original file stays right where it was.

A common early mistake is that if a file with the same name already exists at the destination, it gets overwritten without confirmation. Check with ls first before copying anything important.

In real work, these are used constantly — backing up a config file (cp), placing a finished file into a different directory (mv), and more.

Linux
Try it (type this into the pseudo terminal)
cp notes.txt notes-copy.txt

🧑‍💻 You can type this command into the Linux pseudo terminal to try it yourself (this page itself has no interactive terminal).

Ad space (banner)
Ad space (in-article)