การจัดการไฟล์และไดเรกทอรี: `mkdir`, `rm`, `cp`, `mv`
เชี่ยวชาญการสร้าง ลบ คัดลอก และย้ายไฟล์กับไดเรกทอรีอย่างมีประสิทธิภาพ
การจัดการไฟล์และไดเรกทอรี: `mkdir`, `rm`, `cp`, `mv` เป็นบทเรียน Linux Command Line Mastery ฟรีบน CoddyKit นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Linux Command Line Mastery และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Linux Command Line Mastery มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
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_documentsAdvanced `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 -pCopying 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.txtCopying 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_dataMoving 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.txtDeleting 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.txtDeleting 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_folderQuick 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).
คำถามที่พบบ่อย
บทเรียน “การจัดการไฟล์และไดเรกทอรี: `mkdir`, `rm`, `cp`, `mv`” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “การจัดการไฟล์และไดเรกทอรี: `mkdir`, `rm`, `cp`, `mv`” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Linux Command Line Mastery ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Linux Command Line Mastery มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “การจัดการไฟล์และไดเรกทอรี: `mkdir`, `rm`, `cp`, `mv`”
เชี่ยวชาญการสร้าง ลบ คัดลอก และย้ายไฟล์กับไดเรกทอรีอย่างมีประสิทธิภาพ คุณปฏิบัติ Linux Command Line Mastery ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Linux Command Line Mastery หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Linux Command Line Mastery บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน
บทเรียน “การจัดการไฟล์และไดเรกทอรี: `mkdir`, `rm`, `cp`, `mv`” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Linux Command Line Mastery นี้ได้ไหม
ได้ บทเรียน Linux Command Line Mastery ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- บทนำสู่เชลล์ Linux
- การนำทางเบื้องต้น: `cd`, `ls`, `pwd`
- การจัดการไฟล์และไดเรกทอรี: `mkdir`, `rm`, `cp`, `mv`
- การขอความช่วยเหลือ: man, --help และ tldr