0Pricing
Linux Command Line Mastery · Lesson

File & Directory Management: `mkdir`, `rm`, `cp`, `mv`

Master creating, deleting, copying, and moving files and directories effectively.

File & Directory Management: `mkdir`, `rm`, `cp`, `mv` is a free Linux Command Line Mastery lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Linux Command Line Mastery learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Mastering File Management

Managing files is a core shell skill. This lesson covers the four essentials: mkdir, cp, mv, and rm — create, copy, move, delete.

Creating Folders with `mkdir`

mkdir (make directory) creates a new folder — just give it a name. Try making one called my_documents.

mkdir my_documents

Advanced `mkdir` Usage

Create several folders at once by listing names. Add -p to build nested directories, creating any missing parents along the way.

mkdir reports project/src/main -p

Copying Files with `cp`

cp (copy) duplicates a file: give it a source and a destination. Here we use touch to make a file first, then copy it.

touch notes.txt
cp notes.txt backup_notes.txt

Copying Folders with `cp -r`

To copy a whole folder, add -r (recursive) so cp grabs the directory and everything inside. Without it, folders are skipped.

mkdir data_folder
touch data_folder/file_a.txt
cp -r data_folder archived_data

Moving Files with `mv`

mv (move) relocates files or folders — like cut and paste. Point it at a source and a destination directory.

touch document.pdf
mkdir important_files
mv document.pdf important_files/

Renaming Files & Folders

Bonus: mv also renames. Move a file to the same place with a new name, and you’ve renamed it.

touch old_report.txt
mv old_report.txt new_report.txt

Deleting Files with `rm`

rm (remove) deletes files — permanently, with no trash to recover from. Always double-check what you’re removing.

touch unwanted.txt
rm unwanted.txt

Deleting Folders with `rm -r`

To delete a non-empty folder, add -r so rm clears the directory and its contents. Extreme caution — this is irreversible.

mkdir empty_folder
rm -r empty_folder

Quick Check: File Management

Imagine you have a file named draft.txt in your current directory. You want to create a new folder called final_docs and then move draft.txt into it, renaming it to final_report.txt in the process. Which sequence of commands would achieve this?

Lesson Summary

Great work! You’ve got file management down: mkdir to create, cp to copy, mv to move or rename, and rm to delete (with -r for folders).

Frequently asked questions

Is the “File & Directory Management: `mkdir`, `rm`, `cp`, `mv`” lesson free?

Yes — the full text of “File & Directory Management: `mkdir`, `rm`, `cp`, `mv`” is free to read here on the web, and the Linux Command Line Mastery course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Linux Command Line Mastery course, upgrade to CoddyKit PRO.

What will I learn in “File & Directory Management: `mkdir`, `rm`, `cp`, `mv`”?

Master creating, deleting, copying, and moving files and directories effectively. You practise Linux Command Line Mastery with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Linux Command Line Mastery?

No prior experience is required. Linux Command Line Mastery on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “File & Directory Management: `mkdir`, `rm`, `cp`, `mv`” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Linux Command Line Mastery lesson?

Yes. Every Linux Command Line Mastery lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Introduction to the Linux Shell
  2. Basic Navigation: `cd`, `ls`, `pwd`
  3. File & Directory Management: `mkdir`, `rm`, `cp`, `mv`
  4. Getting Help: man, --help, and tldr
← Back to Linux Command Line Mastery