File Management Basics (mkdir, cp, mv, rm)
Understand how to create, copy, move, and delete files and directories efficiently using essential command-line tools.
File Management Basics (mkdir, cp, mv, rm) is a free Linux Command Line & Bash Scripting Mastery lesson on CoddyKit. This is 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 & Bash Scripting Mastery learning path, and your progress syncs across the web and the CoddyKit app. The Linux Command Line & Bash Scripting Mastery course includes 4 lessons in total.
Linux File Management
Now you'll manage files: creating, copying, moving, and deleting from the terminal. It's a fundamental skill for any Linux user or developer.
Making New Directories: mkdir
mkdir (make directory) creates new folders. Just type mkdir followed by the name you want, as shown.
mkdir my_new_folderCreating Multiple & Nested Directories
List several names to create many folders at once. Add -p to build nested paths, creating any missing parent directories along the way.
mkdir folder1 folder2
mkdir -p projects/coddykit/lesson_filesCopying Files: cp
cp (copy) duplicates a file: give it a source and a destination. Here it copies report.txt to report_backup.txt in the same folder.
cp report.txt report_backup.txtCopying Files to a Directory
Point cp at a directory and the file copies into it, keeping its original name. Handy for filing things away.
mkdir documents
cp presentation.pdf documents/Copying Entire Directories: cp -r
To copy a folder and everything inside, add -r (recursive). Without it, cp refuses to copy directories.
cp -r my_project_folder backup_projects/Moving Files: mv
mv (move) relocates files or directories. It works like cp, but the original is removed after the move.
mv important_note.txt new_location/Renaming Files and Directories
mv also renames: move an item to a new name in the same folder. Linux has no separate rename command - mv does both.
mv old_filename.txt new_filename.txt
mv temp_folder/ final_project_folder/Deleting Files: rm
rm (remove) deletes files - use it carefully. There's usually no trash bin in the terminal, so deleted files are often gone for good.
rm unwanted_log.txtDeleting Directories: rm -r
Empty folders go with rmdir; non-empty ones need rm -r (recursive). Adding -f forces it - so handle rm -rf with extreme care.
mkdir empty_folder
rmdir empty_folder
mkdir project_data && touch project_data/file.txt
rm -r project_data/Quick Check: File Operations
Which of the following commands are used to create a new directory named reports and then copy a directory named data (including its contents) into it?
Recap: File Management Basics
Recap: mkdir creates, cp copies (-r for folders), mv moves and renames, and rm deletes (-r for folders, with care). Your file-management toolkit.
Learn Bash with an AI tutor — free
Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.
- Courses
- 22
- Lessons
- 88
Frequently Asked Questions
Is the “File Management Basics (mkdir, cp, mv, rm)” lesson free?
Yes — the full text of “File Management Basics (mkdir, cp, mv, rm)” is free to read here on the web. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Linux Command Line & Bash Scripting Mastery course, upgrade to CoddyKit PRO. The Linux Command Line & Bash Scripting Mastery course includes 4 lessons in total.
What will I learn in “File Management Basics (mkdir, cp, mv, rm)”?
Understand how to create, copy, move, and delete files and directories efficiently using essential command-line tools. You practise Linux Command Line & Bash Scripting 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 & Bash Scripting Mastery?
No prior experience is required. Linux Command Line & Bash Scripting Mastery on CoddyKit is structured for beginners through advanced learners, so you can start here or from the beginning and move at your own pace. This is lesson 3 of 4.
How long does the “File Management Basics (mkdir, cp, mv, rm)” 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 & Bash Scripting Mastery lesson?
Yes. Every Linux Command Line & Bash Scripting 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
- Introduction to Linux & Terminal
- Navigating the Filesystem (cd, ls, pwd)
- File Management Basics (mkdir, cp, mv, rm)
- Tab Completion & Command History