The path
🐧 First StepsLesson 6 of 30 5 min 30 XP

✂️Copy, move, rename and delete

cp, mv and rm: the three commands that shuffle your stuff around.

Commands in this lesson

cp facts.txt facts-backup.txtCopy a file
cp -r penguins penguins-copyCopy a whole folder
mv facts-backup.txt notes/facts.txtMove it into another folder
mv facts.txt penguin-facts.txtRename it (same thing as moving)
rm penguin-facts.txtDelete it

Notice something? Linux has no separate rename command. Renaming is just moving a file to a new name in the same folder.

⚠️ rm has no undo

There is no bin to fish things out of. rm deletes immediately. Never type rm -rf on a folder unless you are completely sure, and never on / .

🔬 The grown-up version

-r means recursive: do it to the folder and everything inside. -f means force: stop asking. Together, rm -rf is the single most destructive pair of flags in Linux, so people often alias rm to a safer wrapper.

🐧 Tux tip

Before you delete something, run ls on it one last time. Two seconds of checking beats an afternoon of regret.

Now you try

This terminal is pretend, so you cannot break anything. Tap a chip or type a command yourself.

tux — bashpractice

Try the commands from this lesson. Type one and press Enter, or tap a chip below.

penguin@tux:~$
try

Quick check

How do you rename a file in Linux?

Why is rm -rf dangerous?

Finished this one?

Mark it done to collect 30 XP and keep your streak growing.