|
← learn.micky.sh ← learn.micky.sh

terminal 101: a beginner's guide to the command line terminal 101: คู่มือเริ่มต้นใช้ command line สำหรับมือใหม่

#terminal#beginners

you’ve always used your computer by clicking icons, dragging files, and tapping buttons. that works fine — but underneath all of that, your computer has always understood text commands. the icons and buttons are just pretty wrappers on top of those commands.

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 all live here. learning 6 commands is all it takes to feel comfortable.

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

  • Mac: press Cmd + Space, type “Terminal”, hit Enter
  • Windows: press the Start key, type “Terminal” (or “PowerShell”), hit Enter

the 6 commands you need

here’s the good news — you only need 6 commands to navigate your computer from the terminal. most of them work identically on Mac and Windows.

what you want to doMacWindowswhat it means
where am i?pwdpwdprint working directory
show what’s herelsdirlist directory contents
go into a foldercd Desktopcd Desktopchange directory
go up one levelcd ..cd .... means “the folder above”
create a foldermkdir my-foldermkdir my-foldermake directory
clear the screenclearclsstart fresh

notice that cd, mkdir, and pwd work exactly the same on both. only ls/dir and clear/cls differ.

try it yourself

here’s an interactive terminal — it behaves like a real one, but runs safely in your browser. toggle between Mac and Windows in the top-right corner.

try this sequence:

  1. pwd — see where you are
  2. ls (Mac) or dir (Windows) — see what’s in the current folder
  3. cd Desktop — move into the Desktop folder
  4. ls or dir — see the files on the Desktop
  5. mkdir my-first-folder — create a new folder
  6. cd my-first-folder — go into the folder you just made
  7. pwd — confirm where you are now

คนส่วนใหญ่ใช้คอมพิวเตอร์ผ่านการคลิกไอคอน ลากไฟล์ และกดปุ่มมาตลอด ซึ่งก็ไม่ได้มีปัญหาอะไรครับ

แต่ถ้าลองถอยออกมาดูจริงๆ คอมพิวเตอร์ไม่ได้เข้าใจปุ่มหรือไอคอนเป็นหลัก มันเข้าใจ คำสั่งข้อความ ต่างหาก

สิ่งที่เราเห็นบนหน้าจอเป็นเหมือนชั้นห่อหุ้มที่ทำให้ใช้ง่ายขึ้น ส่วน terminal คือการคุยกับคอมพิวเตอร์ตรงๆ โดยไม่ผ่านชั้นนั้น

ทำไมต้องรู้?

ถ้าคุณเริ่มเข้าสู่โลกของ programming, AI tools หรือ developer workflow ยังไงก็ต้องเจอ terminal ครับ

เครื่องมืออย่าง git, node, python และ Claude Code ล้วนอยู่ในนี้ ข่าวดีคือ คุณไม่จำเป็นต้องรู้ทุกอย่างเพื่อเริ่มต้น

สำหรับการใช้งานจริงในชีวิตประจำวัน แค่รู้ 6 คำสั่งนี้ก็ไปต่อได้ไกลมากแล้ว

Terminal คืออะไร?

terminal คือหน้าต่างที่คุณ พิมพ์คำสั่ง ให้คอมพิวเตอร์ทำงาน แทนการคลิกปุ่มต่างๆ

  • GUI (ที่คุณใช้อยู่) = หน้าจอแบบมีปุ่ม เมนู หน้าต่าง — คุณคลิก
  • Terminal = หน้าจอแบบข้อความที่คุณพิมพ์คำสั่ง — คอมพิวเตอร์ตอบเป็นข้อความ

จริงๆ ก็เป็นคอมพิวเตอร์เครื่องเดิมครับ แค่เปลี่ยนวิธีสั่งงาน

วิธีเปิด Terminal

  • Mac: กด Cmd + Space พิมพ์ “Terminal” แล้วกด Enter
  • Windows: กดปุ่ม Start พิมพ์ “Terminal” (หรือ “PowerShell”) แล้วกด Enter

6 คำสั่งที่คุณต้องรู้

ถ้าเพิ่งเริ่ม ผมไม่อยากให้มอง terminal เป็นภาษาลับที่ต้องท่องเยอะๆ

เอาแค่ 6 คำสั่งนี้ก่อนครับ ส่วนใหญ่ใช้ได้เหมือนกันทั้ง Mac และ Windows และเพียงพอสำหรับการเดินไฟล์ในเครื่องแทบทุกวัน

สิ่งที่อยากทำMacWindowsความหมาย
ฉันอยู่ที่ไหน?pwdpwdprint working directory
ดูว่ามีอะไรอยู่lsdirแสดงรายการไฟล์ในโฟลเดอร์
เข้าไปในโฟลเดอร์cd Desktopcd Desktopchange directory
ถอยกลับขึ้นไปหนึ่งชั้นcd ..cd .... แปลว่า “โฟลเดอร์ข้างบน”
สร้างโฟลเดอร์mkdir my-foldermkdir my-foldermake directory
เคลียร์หน้าจอclearclsเริ่มใหม่

จะเห็นว่า cd, mkdir และ pwd ใช้เหมือนกันทุกประการ ต่างกันจริงๆ แค่ ls/dir กับ clear/cls

ลองเล่นดู

ข้างล่างนี้คือ interactive terminal ที่จำลองให้ใกล้เคียงของจริง แต่รันอยู่ในเบราว์เซอร์อย่างปลอดภัย

คุณสามารถกดสลับ Mac/Windows ได้ที่มุมขวาบน

ลองทำตามนี้:

  1. pwd — ดูว่าคุณอยู่ที่ไหน
  2. ls (Mac) หรือ dir (Windows) — ดูว่ามีอะไรอยู่ในโฟลเดอร์
  3. cd Desktop — เข้าไปในโฟลเดอร์ Desktop
  4. ls หรือ dir — ดูไฟล์บน Desktop
  5. mkdir my-first-folder — สร้างโฟลเดอร์ใหม่
  6. cd my-first-folder — เข้าไปในโฟลเดอร์ที่เพิ่งสร้าง
  7. pwd — ยืนยันว่าคุณอยู่ที่ไหนแล้ว
Terminal — zsh
Type 'help' to see available commands. Try: pwd, ls, cd Desktop
/ $ 

understanding file paths

when you type pwd, you get something like /Users/student/Desktop. that’s a file path — it’s like a home address for 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)

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.pdf

works from anywhere — it’s the complete address from the root.

2. from where i’m standing (relative path)

./report.pdf
report.pdf

both mean “the file called report.pdf in the folder i’m currently in.”

3. go back first, then forward

../Documents/report.pdf

means “go up one level (..), then into Documents, then find report.pdf.”

the ~ shortcut

on Mac, ~ means “my home folder.” so ~/Desktop is a shortcut for /Users/yourname/Desktop. try typing cd ~ in the terminal above to jump home.

common mistakes

case sensitivity matters. Desktop and desktop are not the same. if cd desktop doesn’t work, check the capitalization.

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 Desktop then cat notes.txt (Mac) or type notes.txt (Windows) — read a text file
  • cd ~/Documents — jump straight to Documents using the ~ shortcut
  • cat resume.docx (Mac) or type resume.docx (Windows) — see what happens with non-text files

what’s next?

that’s it — you know enough terminal to be productive. these 6 commands cover 90% of what you’ll need day-to-day.

from here, the terminal opens up a world of powerful tools. if you’re interested in AI-assisted development, tools like claude code run entirely in the terminal — and now you know how to get around.

more posts coming soon on practical workflows that build on these foundations.

ทำความเข้าใจ file path

เวลาคุณพิมพ์ pwd คุณจะได้ผลลัพธ์ประมาณ /Users/student/Desktop

สิ่งนั้นคือ file path ถ้าจะอธิบายแบบง่ายที่สุด มันก็คือ “ที่อยู่” ของตำแหน่งที่คุณกำลังยืนอยู่บนคอมพิวเตอร์

ลองคิดแบบนี้:

/Users/student/Desktop

/          → คอมพิวเตอร์ทั้งเครื่อง (ประเทศ)
Users/     → ที่เก็บ account ผู้ใช้ทั้งหมด (จังหวัด)
student/   → account ของคุณ (บ้าน)
Desktop/   → โฟลเดอร์ในบ้านคุณ (ห้อง)

ทุก / (หรือ \ บน 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 ตัว ~ หมายถึง “home folder ของฉัน”

ดังนั้น ~/Desktop จึงเป็นทางลัดของ /Users/ชื่อคุณ/Desktop ถ้าลองพิมพ์ cd ~ ใน terminal ด้านบน คุณจะกลับไปที่ home ได้ทันที

ข้อผิดพลาดที่พบบ่อย

ตัวพิมพ์ใหญ่-เล็กสำคัญ Desktop กับ desktop ไม่ใช่อันเดียวกัน ถ้า cd desktop ไม่ทำงาน ให้เช็กเรื่องตัวพิมพ์ก่อน

ชื่อโฟลเดอร์ที่มีเว้นวรรคควรใส่เครื่องหมายคำพูด ถ้าโฟลเดอร์ชื่อ “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) — ดูว่าเกิดอะไรขึ้นกับไฟล์ที่ไม่ใช่ข้อความ

แล้วต่อไปล่ะ?

เท่านี้คุณก็รู้ terminal มากพอที่จะเริ่มใช้งานจริงได้แล้วครับ

6 คำสั่งนี้ครอบคลุมงานพื้นฐานส่วนใหญ่ที่ต้องใช้ในแต่ละวัน

จากตรงนี้ terminal จะพาคุณไปเจอกับเครื่องมืออีกเยอะมาก

ถ้าคุณสนใจ AI-assisted development, เครื่องมืออย่าง Claude Code ก็ทำงานอยู่บน terminal เกือบทั้งหมด และตอนนี้อย่างน้อยคุณก็รู้แล้วว่าจะเดินไปไหนต่อยังไง

โพสต์ถัดไปผมน่าจะค่อยๆ ต่อจากพื้นฐานพวกนี้ไปทีละขั้น ถ้ามีจุดไหนที่อยากให้ขยายเพิ่ม บอกกันได้เลยนะครับ

← back to all posts ← กลับหน้าหลัก