terminal 101: a beginner's guide to the command line terminal 101: คู่มือเริ่มต้นใช้ command line สำหรับมือใหม่
learn the 6 essential terminal commands that make the command line feel usable, with an interactive terminal you can practice in right here ทำความรู้จัก 6 คำสั่ง terminal พื้นฐานที่ช่วยให้ command line เข้าใจง่ายขึ้น พร้อม terminal แบบโต้ตอบให้ลองเล่นได้เลยในหน้านี้
you’ve always used your computer by clicking icons, dragging files, and tapping buttons. that works fine — but underneath all of that, your computer also understands text commands. the icons and buttons are another layer on top.
a terminal removes the wrapper and lets you talk directly.
why should i care?
if you’re getting into programming, AI tools, or developer workflows, you’re going to run into the terminal. tools like git, node, python, and claude code show up here constantly. learning 6 commands won’t teach you everything, but it will make the terminal feel much less foreign.
what is a terminal?
a terminal is a window where you type instructions to your computer instead of clicking.
- GUI (what you’re used to) = visual interface with buttons, menus, windows — you click
- Terminal = text interface where you type commands — the computer responds with text
that’s it. same computer, different interface.
how to open it
if you’re on Windows, this lesson assumes PowerShell — either the standalone PowerShell app or a PowerShell tab inside Windows Terminal.
- Mac: press
Cmd + Space, type “Terminal”, hit Enter - Windows: press the Start key, open “Windows Terminal” or “PowerShell”, then use a PowerShell tab
what you’ll know by the end
- how to see where you are (
pwd) and what’s around you (ls/dir) - how to move between folders with
cdandcd .. - how to create a folder with
mkdirand clear the screen - how to read file paths (
/,.,.., and~) - a few common mistakes that trip up beginners
what this assumes
nothing. this is the first post. if you can open Terminal (Mac) or PowerShell (Windows), you’re ready.
the 6 commands you need
to get comfortable moving around, you only need 6 commands. most of them work the same on Mac and Windows PowerShell.
| what you want to do | Mac | Windows (PowerShell) | what it means |
|---|---|---|---|
| where am i? | pwd | pwd | print working directory |
| show what’s here | ls | dir | list directory contents |
| go into a folder | cd Desktop | cd Desktop | change directory |
| go up one level | cd .. | cd .. | .. means “the folder above” |
| create a folder | mkdir my-folder | mkdir my-folder | make directory |
| clear the screen | clear | cls | start fresh |
notice that cd, mkdir, and pwd work exactly the same on both. for this lesson, treat ls/dir and clear/cls as the differences. PowerShell also accepts some aliases like ls, but dir is the Windows word beginners will see often.
try it yourself
here’s an interactive terminal — it runs safely in your browser and is close enough to a real one to practice the basics. toggle between Mac and Windows in the top-right corner.
try this sequence:
pwd— see where you arels(Mac) ordir(Windows) — see what’s in the current foldercd Desktop— move into the Desktop folderlsordir— see the files on the Desktopmkdir my-first-folder— create a new foldercd my-first-folder— go into the folder you just madepwd— confirm where you are now
checkpoint: after step 7, your path should end with Desktop/my-first-folder on Mac or Desktop\my-first-folder on Windows. if it does not, type cd ~ and start the sequence again from home.
คนส่วนใหญ่ใช้คอมพิวเตอร์ผ่านการคลิกไอคอน ลากไฟล์ และกดปุ่มมาตลอด ซึ่งก็ไม่ได้มีปัญหาอะไรครับ
แต่ถ้าลองถอยออกมาดูจริงๆ คอมพิวเตอร์ก็เข้าใจ คำสั่งข้อความ ได้เหมือนกัน
สิ่งที่เราเห็นบนหน้าจอเป็นชั้นที่ทำให้ใช้ง่ายขึ้น ส่วน terminal คือการคุยกับคอมพิวเตอร์ตรงๆ โดยไม่ผ่านชั้นนั้น
ทำไมต้องรู้?
ถ้าคุณเริ่มเข้าสู่โลกของการเขียนโปรแกรม เครื่องมือ AI หรือการทำงานสายพัฒนา ยังไงก็ต้องเจอ terminal ครับ
เครื่องมืออย่าง git, node, python และ Claude Code โผล่มาในนี้ตลอด ข่าวดีคือ คุณไม่จำเป็นต้องรู้ทั้งหมดเพื่อเริ่มต้น
แค่รู้ 6 คำสั่งนี้ คุณก็จะเริ่มใช้งานได้แบบไม่งงแล้ว
Terminal คืออะไร?
terminal คือหน้าต่างที่คุณ พิมพ์คำสั่ง ให้คอมพิวเตอร์ทำงาน แทนการคลิกปุ่มต่างๆ
- GUI (ที่คุณใช้อยู่) = หน้าจอแบบมีปุ่ม เมนู หน้าต่าง — คุณคลิก
- Terminal = หน้าจอแบบข้อความที่คุณพิมพ์คำสั่ง — คอมพิวเตอร์ตอบเป็นข้อความ
จริงๆ ก็เป็นคอมพิวเตอร์เครื่องเดิมครับ แค่เปลี่ยนวิธีสั่งงาน
วิธีเปิด Terminal
ถ้าใช้ Windows บทนี้จะอิงคำสั่งแบบ PowerShell ครับ จะเป็นแอป PowerShell แยก หรือแท็บ PowerShell ใน Windows Terminal ก็ได้เหมือนกัน
- Mac: กด
Cmd + Spaceพิมพ์ “Terminal” แล้วกด Enter - Windows: กดปุ่ม Start แล้วเปิด “Windows Terminal” หรือ “PowerShell” จากนั้นใช้แท็บ PowerShell
จบโพสต์นี้แล้วจะทำอะไรได้บ้าง
- ดูว่าอยู่ที่ไหน (
pwd) และมีอะไรอยู่รอบตัว (ls/dir) - เดินระหว่างโฟลเดอร์ด้วย
cdและcd .. - สร้างโฟลเดอร์ด้วย
mkdirและเคลียร์หน้าจอ - อ่าน path ไฟล์ได้ (
/,.,.., และ~) - รู้จักข้อผิดพลาดที่มือใหม่มักเจอ
โพสต์นี้เริ่มจากไหน
ไม่ต้องมีอะไรมาก่อนเลยครับ นี่คือโพสต์แรก ถ้าเปิด Terminal (Mac) หรือ PowerShell (Windows) ได้ ก็พร้อมแล้ว
6 คำสั่งที่คุณต้องรู้
ถ้าเพิ่งเริ่ม ผมไม่อยากให้มอง terminal เป็นภาษาลับที่ต้องท่องเยอะๆ
เอาแค่ 6 คำสั่งนี้ก่อนครับ ส่วนใหญ่ใช้ได้เหมือนกันทั้ง Mac และ Windows PowerShell และพอสำหรับการเดินดูไฟล์และโฟลเดอร์ในเครื่องแบบที่ใช้บ่อยจริง
| สิ่งที่อยากทำ | Mac | Windows (PowerShell) | ความหมาย |
|---|---|---|---|
| ฉันอยู่ที่ไหน? | pwd | pwd | print working directory |
| ดูว่ามีอะไรอยู่ | ls | dir | แสดงรายการไฟล์ในโฟลเดอร์ |
| เข้าไปในโฟลเดอร์ | cd Desktop | cd Desktop | change directory |
| ถอยกลับขึ้นไปหนึ่งชั้น | cd .. | cd .. | .. แปลว่า “โฟลเดอร์ข้างบน” |
| สร้างโฟลเดอร์ | mkdir my-folder | mkdir my-folder | make directory |
| เคลียร์หน้าจอ | clear | cls | เริ่มใหม่ |
จะเห็นว่า cd, mkdir และ pwd ใช้เหมือนกันทุกประการ
ในบทนี้ให้จำว่า ls/dir กับ clear/cls คือจุดที่ต่างกันครับ PowerShell จริงอาจรับ alias อย่าง ls ได้ด้วย แต่ dir เป็นคำฝั่ง Windows ที่มือใหม่จะเจอบ่อย
ลองเล่นดู
ข้างล่างนี้คือ terminal แบบโต้ตอบที่จำลองให้ใกล้เคียงของจริงพอสำหรับฝึกพื้นฐาน แต่รันอยู่ในเบราว์เซอร์อย่างปลอดภัย
คุณสามารถกดสลับ Mac/Windows ได้ที่มุมขวาบน
ลองทำตามนี้:
pwd— ดูว่าคุณอยู่ที่ไหนls(Mac) หรือdir(Windows) — ดูว่ามีอะไรอยู่ในโฟลเดอร์cd Desktop— เข้าไปในโฟลเดอร์ Desktoplsหรือdir— ดูไฟล์บน Desktopmkdir my-first-folder— สร้างโฟลเดอร์ใหม่cd my-first-folder— เข้าไปในโฟลเดอร์ที่เพิ่งสร้างpwd— ยืนยันว่าคุณอยู่ที่ไหนแล้ว
จุดเช็ก: หลังข้อ 7 path ของคุณควรลงท้ายด้วย Desktop/my-first-folder บน Mac หรือ Desktop\my-first-folder บน Windows ถ้าไม่ใช่ ให้พิมพ์ cd ~ แล้วเริ่มลำดับใหม่จาก home
understanding file paths
when you type pwd, you get something like /Users/student/Desktop. that’s a file path — the address of where you are on your computer.
think of it this way:
/Users/student/Desktop
/ → the entire computer (the country)
Users/ → where all user accounts live (the city)
student/ → your account (your house)
Desktop/ → a folder inside your account (a room)Read a path like an address
every / (or \ on Windows) means “go one level deeper.”
three ways to point to a file
1. full address (absolute path)
/Users/student/Documents/report.pdfworks from anywhere — it’s the complete address from the root.
2. from where i’m standing (relative path)
./report.pdf
report.pdfboth mean “the file called report.pdf in the folder i’m currently in.”
3. go back first, then forward
../Documents/report.pdfmeans “go up one level (..), then into Documents, then find report.pdf.”
the ~ shortcut
on Mac and in PowerShell, ~ means “my home folder.” so ~/Desktop is a shortcut for /Users/yourname/Desktop (Mac) or C:\Users\yourname\Desktop (Windows). try typing cd ~ in the terminal above to jump home.
common mistakes
match the real capitalization. the simulator, Linux, and some macOS setups treat Desktop and desktop as different. Windows and many default Mac setups are more forgiving, but using the real case is the safest habit.
spaces in folder names need quoting. if a folder is called “My Documents”, you’d type cd "My Documents" — or better yet, avoid spaces in folder names.
you might be in the wrong folder. if a command says “file not found,” you’re probably not where you think you are. type pwd to check.
try reading files
the terminal above also supports reading files. try:
cd ~/Desktopthencat notes.txt(Mac) ortype notes.txt(Windows) — read a text filecd ~/Documents— jump straight to Documents using the~shortcutcat resume.docx(Mac) ortype resume.docx(Windows) — see what happens with non-text files
official reference
if you’re on Windows and want the real command reference behind this lesson’s PowerShell examples, start here:
what’s next?
that’s enough to start using the terminal without feeling lost. these 6 commands cover the basic movement you’ll do over and over.
from here, the next useful step is changing files without panicking.
next up: terminal 102 — files without fear. that’s where you learn touch, cp, mv, rm, hidden files, quoted paths, and the one safety habit that matters most before you start editing real project folders.
ทำความเข้าใจเส้นทางไฟล์
เวลาคุณพิมพ์ pwd คุณจะได้ผลลัพธ์ประมาณ /Users/student/Desktop
สิ่งนั้นคือ เส้นทางไฟล์ ถ้าจะอธิบายแบบง่ายที่สุด มันก็คือ “ที่อยู่” ของตำแหน่งที่คุณกำลังยืนอยู่บนคอมพิวเตอร์
ลองคิดแบบนี้:
/Users/student/Desktop
/ → คอมพิวเตอร์ทั้งเครื่อง (ประเทศ)
Users/ → ที่เก็บบัญชีผู้ใช้ทั้งหมด (จังหวัด)
student/ → บัญชีของคุณ (บ้าน)
Desktop/ → โฟลเดอร์ในบ้านคุณ (ห้อง)อ่าน path ให้เหมือนอ่านที่อยู่
ทุก / (หรือ \ บน Windows) คือการบอกว่าเรากำลังเดินลึกลงไปอีกหนึ่งชั้น
3 วิธีชี้ไปที่ไฟล์
1. ที่อยู่เต็ม (absolute path)
/Users/student/Documents/report.pdfใช้ได้จากทุกที่ เพราะเป็นที่อยู่เต็มตั้งแต่จุดเริ่มต้น
2. จากจุดที่ยืนอยู่ (relative path)
./report.pdf
report.pdfทั้งสองแบบแปลว่า “ไฟล์ชื่อ report.pdf ที่อยู่ในโฟลเดอร์ที่ฉันยืนอยู่ตอนนี้”
3. ถอยกลับก่อน แล้วค่อยเดินไป
../Documents/report.pdfแปลว่า “ถอยขึ้นไปหนึ่งชั้น (..) แล้วค่อยเดินเข้าไปใน Documents เพื่อหา report.pdf”
ทางลัด ~
บน Mac และใน PowerShell ตัว ~ หมายถึง “home folder ของฉัน”
ดังนั้น ~/Desktop จึงเป็นทางลัดของ /Users/ชื่อคุณ/Desktop (Mac) หรือ C:\Users\ชื่อคุณ\Desktop (Windows)
ถ้าลองพิมพ์ cd ~ ใน terminal ด้านบน คุณจะกลับไปที่ home ได้ทันที
ข้อผิดพลาดที่พบบ่อย
พิมพ์ชื่อตามตัวจริงไว้ก่อนดีที่สุด ตัวจำลองนี้, Linux และ macOS บางเครื่องจะแยก Desktop กับ desktop ออกจากกัน ส่วน Windows และ Mac หลายเครื่องอาจยืดหยุ่นกว่า แต่การพิมพ์ให้ตรงกับชื่อจริงเป็นนิสัยที่ปลอดภัยที่สุด
ชื่อโฟลเดอร์ที่มีเว้นวรรคควรใส่เครื่องหมายคำพูด ถ้าโฟลเดอร์ชื่อ “My Documents” คุณต้องพิมพ์ cd "My Documents" หรือถ้าตั้งชื่อเองได้ก็ควรเลี่ยงเว้นวรรคไปเลย
คุณอาจยืนอยู่ผิดที่ ถ้าคำสั่งบอกว่า “file not found” หลายครั้งปัญหาไม่ได้อยู่ที่ไฟล์หาย แต่อยู่ที่เราอยู่ผิดโฟลเดอร์ ลองพิมพ์ pwd เพื่อตรวจสอบก่อน
ลองอ่านไฟล์ดู
terminal ด้านบนรองรับการอ่านไฟล์ด้วย ลองต่อจากเดิมแบบนี้ได้เลย:
cd ~/Desktopแล้วcat notes.txt(Mac) หรือtype notes.txt(Windows) — อ่านไฟล์ข้อความcd ~/Documents— กระโดดไปที่ Documents โดยใช้ทางลัด~cat resume.docx(Mac) หรือtype resume.docx(Windows) — ดูว่าเกิดอะไรขึ้นกับไฟล์ที่ไม่ใช่ข้อความ
อ้างอิงทางการ
ถ้าใช้ Windows แล้วอยากดูเอกสารจริงของคำสั่งแบบ PowerShell ที่บทนี้อิงอยู่ ให้เริ่มจากหน้านี้ครับ:
แล้วต่อไปล่ะ?
เท่านี้คุณก็รู้ terminal มากพอที่จะเริ่มใช้งานโดยไม่หลงแล้วครับ
6 คำสั่งนี้ครอบคลุมการเดินดูไฟล์และโฟลเดอร์ที่ต้องใช้บ่อยในแต่ละวัน
จากตรงนี้ ก้าวที่มีประโยชน์ที่สุดต่อไปคือเริ่ม “เปลี่ยน” ไฟล์โดยไม่ต้องกลัวครับ
ตอนต่อไป: terminal 102 — files without fear
ตรงนั้นคุณจะได้รู้จัก touch, cp, mv, rm, ไฟล์ที่ซ่อนอยู่, path ที่มีเว้นวรรค, และนิสัยความปลอดภัยข้อสำคัญที่สุดก่อนจะเริ่มแตะโฟลเดอร์โปรเจ็กต์จริง