🚀 Advanced Linux Tutorials

บทเรียน Linux ขั้นสูง

Take Your Linux Skills to the Next Level

ยกระดับทักษะ Linux ของคุณ

🎉 ยินดีด้วย! Congratulations!

คุณพร้อมที่จะเรียนรู้เทคนิคขั้นสูงแล้ว!

You're ready to learn advanced techniques!

ในหน้านี้ คุณจะได้เรียนรู้การใช้ Linux ในงานจริง สร้างโปรเจกต์ที่น่าสนใจ และเรียนรู้เคล็ดลับจากมืออาชีพ

In this section, you'll learn real-world Linux usage, build exciting projects, and discover professional tips!

💻 บทเรียนที่ 1
Tutorial 1

📁

File Management Master
การจัดการไฟล์แบบมืออาชีพ 🌱 Easy

สิ่งที่คุณจะได้เรียนรู้:

  • การย้ายและคัดลอกไฟล์อย่างมีประสิทธิภาพ
  • การค้นหาไฟล์อย่างรวดเร็ว
  • การจัดระเบียบไฟล์แบบมืออาชีพ
  • การสำรองข้อมูลอย่างง่าย

What You'll Learn:

Master file management in Linux! You'll learn how to efficiently move and copy files, search for files quickly, organize like a professional, and create simple backups.

1การคัดลอกไฟล์ - Copy Files

คำสั่ง cp (copy) ใช้สำหรับคัดลอกไฟล์หรือโฟลเดอร์

The cp command is used to copy files or folders. It's one of the most frequently used commands in Linux.

# Copy a single file # คัดลอกไฟล์เดียว cp file1.txt file2.txt # Copy a file to another directory # คัดลอกไฟล์ไปยังโฟลเดอร์อื่น cp file1.txt /home/user/documents/ # Copy entire folder with all contents # คัดลอกโฟลเดอร์ทั้งหมดพร้อมเนื้อหาข้างใน cp -r my-folder/ my-folder-backup/

2การย้ายไฟล์ - Move Files

คำสั่ง mv (move) ใช้ย้ายไฟล์หรือเปลี่ยนชื่อ

The mv command moves files or renames them. It's like cut and paste in a graphical interface.

# Move a file to another location # ย้ายไฟล์ไปที่อื่น mv file1.txt /home/user/documents/ # Rename a file (move to same location with new name) # เปลี่ยนชื่อไฟล์ mv oldname.txt newname.txt # Move multiple files at once # ย้ายหลายไฟล์พร้อมกัน mv *.txt /home/user/documents/

3การค้นหาไฟล์ - Find Files

คำสั่ง find ช่วยค้นหาไฟล์ในระบบ ทรงพลังมาก!

The find command searches for files in your system. It's incredibly powerful and flexible!

# Find all .txt files in current directory # ค้นหาไฟล์ .txt ทั้งหมดในโฟลเดอร์ปัจจุบัน find . -name "*.txt" # Find files modified in last 7 days # ค้นหาไฟล์ที่แก้ไขใน 7 วันที่ผ่านมา find . -mtime -7 # Find large files (bigger than 100MB) # ค้นหาไฟล์ขนาดใหญ่ (มากกว่า 100MB) find . -size +100M

4การสร้างโครงสร้างโฟลเดอร์ - Create Folder Structure

มาสร้างโครงสร้างโฟลเดอร์แบบมืออาชีพสำหรับโปรเจกต์กัน!

Let's create a professional folder structure for a project! This is how developers organize their work.

# Create main project folder mkdir my-project # Create multiple subdirectories at once mkdir -p my-project/{src,docs,tests,config} # View the structure tree my-project # Or use: ls -R my-project
💡 Pro Tip: ใช้ Tab key เพื่อทำ Auto-complete ชื่อไฟล์! พิมพ์แค่ 2-3 ตัวแรก แล้วกด Tab ระบบจะเติมชื่อให้เอง ประหยัดเวลามาก!

English: Use the Tab key for auto-completion! Type the first 2-3 characters of a filename, then press Tab. The system will complete it for you - huge time saver!

⚠️ Common Mistake: อย่าใช้ rm -rf / เด็ดขาด! คำสั่งนี้จะลบไฟล์ทั้งหมดในระบบ!

English: Never use rm -rf / - this command will delete everything on your system! Always double-check before using rm with -rf flags.

🔍 บทเรียนที่ 2
Tutorial 2

📊

System Monitoring & Process Management
การตรวจสอบระบบและจัดการโปรเซส 🔍 Medium

สิ่งที่คุณจะได้เรียนรู้:

  • การดูสถานะของระบบ
  • การจัดการโปรแกรมที่ทำงานอยู่
  • การตรวจสอบการใช้ทรัพยากร
  • การแก้ปัญหาเบื้องต้น

What You'll Build:

Learn to monitor your Linux system like a professional! You'll understand how to check system status, manage running programs, monitor resource usage, and troubleshoot basic issues.

1ดูโปรแกรมที่ทำงาน - View Running Processes

คำสั่ง ps และ top แสดงโปรแกรมที่กำลังทำงาน

The ps and top commands show running processes. Top is interactive and updates in real-time!

# Show all your processes # แสดงโปรเซสทั้งหมดของคุณ ps aux # Interactive process viewer (Press 'q' to quit) # ดูโปรเซสแบบเรียลไทม์ (กด 'q' เพื่อออก) top # Better alternative to top - more colorful! # ทางเลือกที่ดีกว่า top - สวยกว่า! htop

2การหยุดโปรแกรม - Stop Processes

เมื่อโปรแกรมค้าง หรือต้องการหยุดการทำงาน ใช้คำสั่ง kill

When a program freezes or you need to stop it, use the kill command. Find the process ID first, then kill it.

# Find process by name # ค้นหาโปรเซสด้วยชื่อ ps aux | grep firefox # Kill process by ID (e.g., ID 1234) # หยุดโปรเซสด้วย ID kill 1234 # Force kill if normal kill doesn't work # บังคับหยุดถ้าคำสั่งปกติไม่ได้ผล kill -9 1234 # Kill all processes with name killall firefox

3ตรวจสอบพื้นที่ดิสก์ - Check Disk Space

คำสั่ง df และ du ช่วยตรวจสอบพื้นที่ฮาร์ดดิสก์

The df and du commands help you monitor disk space usage. Essential for keeping your system healthy!

# Show disk space in human-readable format # แสดงพื้นที่ดิสก์ในรูปแบบอ่านง่าย df -h # Check size of current directory # ตรวจสอบขนาดของโฟลเดอร์ปัจจุบัน du -sh # Find largest directories du -h --max-depth=1 | sort -hr | head -10

4ดูข้อมูลระบบ - View System Information

มาดูข้อมูลเกี่ยวกับระบบของคุณกัน!

Let's explore your system information! These commands reveal everything about your Linux setup.

# Show system information # แสดงข้อมูลระบบ uname -a # Show CPU information # ข้อมูล CPU lscpu # Show memory usage # การใช้งาน RAM free -h # Show uptime (how long system has been running) uptime
💡 Pro Tip: กด Ctrl + C เพื่อหยุดคำสั่งที่กำลังรันอยู่ และกด Ctrl + Z เพื่อพักการทำงานชั่วคราว

English: Press Ctrl plus C to stop a running command, and Ctrl plus Z to pause it temporarily. These keyboard shortcuts are essential!

🎨 บทเรียนที่ 3
Tutorial 3

🔧

Bash Scripting - Automate Your Work
การเขียน Bash Script - ทำงานอัตโนมัติ 🏆 Hard

สิ่งที่คุณจะได้เรียนรู้:

  • การเขียนสคริปต์พื้นฐาน
  • การทำงานอัตโนมัติ
  • การใช้ตัวแปรและลูป
  • สร้างเครื่องมือของตัวเอง

What You'll Build:

Learn to write Bash scripts and automate repetitive tasks! You'll create your own tools, use variables and loops, and become more productive.

1สคริปต์แรกของคุณ - Your First Script

มาสร้างสคริปต์ง่ายๆ ที่ทำงานอัตโนมัติกัน!

Let's create a simple script that automates a task! We'll make a backup script.

#!/bin/bash # My first backup script # สคริปต์สำรองข้อมูลแรกของฉัน # Create backup directory mkdir -p ~/backups # Get current date DATE=$(date +%Y-%m-%d) # Backup documents cp -r ~/Documents ~/backups/documents-$DATE echo "Backup completed: $DATE"

วิธีสร้างและรันสคริปต์:

# Create the script file nano backup.sh # Make it executable chmod +x backup.sh # Run the script ./backup.sh

2ใช้ตัวแปร - Using Variables

ตัวแปรช่วยเก็บข้อมูลและทำให้สคริปต์ยืดหยุ่นมากขึ้น

Variables store data and make your scripts more flexible and powerful!

#!/bin/bash # Define variables # กำหนดตัวแปร NAME="John" AGE=25 GREETING="Hello, $NAME! You are $AGE years old." # Print the greeting echo $GREETING # Get user input read -p "Enter your name: " USERNAME echo "Welcome, $USERNAME!"

3ลูปและเงื่อนไข - Loops and Conditions

ทำซ้ำงานหลายๆ ครั้งด้วยลูป และตัดสินใจด้วยเงื่อนไข

Repeat tasks with loops and make decisions with conditions! This makes scripts truly powerful.

#!/bin/bash # For loop example # ตัวอย่างลูป for for i in {1..5} do echo "Number $i" done # If-else condition # เงื่อนไข if-else read -p "Enter a number: " NUM if [ $NUM -gt 10 ] then echo "Number is greater than 10" else echo "Number is 10 or less" fi

4สคริปต์ที่มีประโยชน์จริง - Practical Script

สร้างสคริปต์ทำความสะอาดระบบ - ลบไฟล์ชั่วคราวและว่างพื้นที่

Create a system cleanup script - remove temporary files and free up space!

#!/bin/bash # System Cleanup Script echo "Starting system cleanup..." # Remove temporary files rm -rf ~/.cache/* # Remove old log files find ~/logs -name "*.log" -mtime +30 -delete # Clear trash rm -rf ~/.local/share/Trash/* # Show disk space before and after df -h ~ echo "Cleanup completed!"
⚠️ Important: ระวังเมื่อใช้คำสั่ง rm ในสคริปต์! ตรวจสอบ path ให้ดีก่อนรัน เพราะไฟล์ที่ถูกลบจะกู้คืนไม่ได้

English: Be careful with the rm command in scripts! Double-check paths before running, because deleted files cannot be recovered.

📚 คู่มืออ้างอิง
Quick Reference

คำสั่งที่ใช้บ่อย - Essential Commands

Command Description (English) คำอธิบาย (ไทย) Example
ls List files แสดงไฟล์ ls -la
cd Change directory เปลี่ยนโฟลเดอร์ cd /home
pwd Print working directory แสดงตำแหน่งปัจจุบัน pwd
mkdir Make directory สร้างโฟลเดอร์ mkdir newfolder
rm Remove files ลบไฟล์ rm file.txt
cp Copy files คัดลอกไฟล์ cp a.txt b.txt
mv Move/rename files ย้าย/เปลี่ยนชื่อ mv old.txt new.txt
cat Display file contents แสดงเนื้อหาไฟล์ cat file.txt
grep Search in files ค้นหาในไฟล์ grep "word" file.txt
chmod Change permissions เปลี่ยนสิทธิ์ chmod +x script.sh
sudo Run as administrator รันด้วยสิทธิ์ admin sudo apt update
man Manual/help คู่มือการใช้ man ls

Best Practices - เทคนิคมืออาชีพ

💡 Professional Tips

  • Always backup before making changes: ใช้ cp หรือ rsync สำรองข้อมูลก่อนแก้ไขสิ่งสำคัญ
  • Use Tab completion: กด Tab เพื่อทำ auto-complete ประหยัดเวลาและลดความผิดพลาด
  • Read the manual: ใช้ man command-name เพื่ออ่านคู่มือก่อนใช้คำสั่งใหม่
  • Test commands safely: ลองคำสั่งในโฟลเดอร์ test ก่อนใช้กับข้อมูลจริง
  • Comment your scripts: เขียน comment ในสคริปต์เพื่อจำได้ว่าโค้ดแต่ละส่วนทำอะไร
  • Use version control: เรียนรู้ Git เพื่อจัดการโค้ดและไฟล์อย่างมืออาชีพ
  • Keep learning: Linux เปลี่ยนแปลงตลอด อ่านบล็อกและติดตามข่าวสารใหม่ๆ

⚠️ Things to Avoid - สิ่งที่ควรหลีกเลี่ยง

  • Don't run unknown scripts: อย่ารันสคริปต์ที่ไม่รู้จักมาจากอินเทอร์เน็ต อ่านก่อนเสมอ
  • Avoid working as root unnecessarily: ใช้ sudo เฉพาะตอนจำเป็น อย่าใช้ root account ตลอดเวลา
  • Don't ignore error messages: อ่านข้อความ error ให้เข้าใจ มันบอกปัญหาที่แท้จริง
  • Avoid complex one-liners: คำสั่งยาวๆ ซับซ้อนอาจทำผิดพลาดง่าย แยกเป็นหลายขั้นตอน
  • Don't disable security features: อย่าปิด firewall หรือ SELinux เพื่อความสะดวก มันคุ้มกันระบบ

🏆 คุณเก่งมาก! You're Doing Great!

คุณได้เรียนรู้เทคนิคขั้นสูงของ Linux แล้ว!

You've learned advanced Linux techniques!

ตอนนี้คุณพร้อมที่จะทดสอบความรู้

Now you're ready to test your knowledge!

ไปทำ Linux Exam เพื่อดูว่าคุณเรียนรู้มาแค่ไหน!