Essential Server Cheatsheet
နေ့စဉ်သုံး Linux & Cloud Engineering Command များ စုစည်းမှု
ဆာဗာ setup ပြုလုပ်ခြင်း၊ Nginx, Docker, Databases, PM2, Firewall နှင့် Emergency ပြဿနာဖြေရှင်းရာတွင် လက်တွေ့အသုံးများသော production commands များကို အမြန်ရှာဖွေပြီး 1-click copy ကူးယူနိုင်ပါသည်။
SSH & Remote Access
SSH လုံခြုံရေးနှင့် သော့စီမံခန့်ခွဲခြင်း
ssh-keygen -t ed25519 -C "admin@example.com"Ed25519 standard ဖြင့် ပေါ့ပါးပြီး အဆင့်မြင့်လုံခြုံသော SSH Key pair အသစ် ထုတ်ယူခြင်း (RSA ထက် ပိုမိုခေတ်မီသည်)
Pro Tip: RSA-4096 ထက် ပိုမိုမြန်ဆန်ပြီး cryptographic attack များကို အထူးခံနိုင်ရည်ရှိပါသည်
ssh-copy-id -i ~/.ssh/id_ed25519.pub <user>@<server_ip>မိမိစက်ရှိ Public Key ကို VPS ဆာဗာ၏ authorized_keys ထဲသို့ အလိုအလျောက် safe ကူးယူထည့်သွင်းခြင်း
Pro Tip: Manual copy လုပ်စရာမလိုဘဲ folder permissions များကိုပါ တစ်ခါတည်း ချိန်ညှိပေးသည်
ssh -i ~/.ssh/id_ed25519 -p <port> <user>@<server_ip>သတ်မှတ်ထားသော Custom SSH Port နှင့် သီးခြား Private Key ဖြင့် ဆာဗာသို့ တိုက်ရိုက် Login ဝင်ရောက်ခြင်း
ssh-add ~/.ssh/id_ed25519Private Key ကို SSH Authentication Agent ထဲသို့ ထည့်သွင်းခြင်း (SSH ဝင်တိုင်း Passphrase ခဏခဏ မရိုက်ရစေရန်)
chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keysSSH directory နှင့် authorized_keys ဖိုင်အား အခြားသူများ ဖတ်မရအောင် ပိုင်ရှင်တစ်ဦးတည်းအတွက်သာ တင်းကျပ်စွာ သတ်မှတ်ခြင်း
Pro Tip: Permissions မှားယွင်းနေပါက OpenSSH daemon က လုံခြုံရေးအရ Key Login ကို အလိုအလျောက်ပယ်ချပါသည်
sudo sshd -t/etc/ssh/sshd_config ဖိုင် syntax အမှားအယွင်း ရှိမရှိ စစ်ဆေးခြင်း (Port ပြောင်းပြီးပါက restart မလုပ်မီ မဖြစ်မနေ စစ်ဆေးပါ)
Pro Tip: Syntax အမှားပါပြီး restart လုပ်မိပါက ဆာဗာသို့ SSH ဝင်မရတော့ဘဲ Lock out ဖြစ်သွားနိုင်ပါသည်
sudo tail -f /var/log/auth.log | grep sshdSSH သို့ ဝင်ရောက်ရန် ကြိုးပမ်းနေမှုများနှင့် Brute-force တိုက်ခိုက်မှုများကို real-time အချိန်နှင့်တပြေးညီ စောင့်ကြည့်ခြင်း
System Resources & Process Monitoring
CPU, RAM နှင့် Processes စောင့်ကြည့်စစ်ဆေးခြင်း
htopCPU cores, RAM, Swap နှင့် running processes များကို dynamic interactive graphical interface ဖြင့် ကြည့်ရှုခြင်း
Pro Tip: F6 နှိပ်၍ CPU/Memory အလိုက် sort လုပ်နိုင်ပြီး F9 နှိပ်၍ process သတ်နိုင်ပါသည်
free -hလက်ရှိ RAM နှင့် Swap အသုံးပြုနေမှု ပမာဏကို လူသားဖတ်ရှုရ လွယ်ကူသော GB/MB ယူနစ်ဖြင့် ရှင်းလင်းစွာ စစ်ဆေးခြင်း
uptimeဆာဗာ ဖွင့်လှစ်ထားသည့်ကြာချိန်နှင့် 1m, 5m, 15m CPU Load Averages များကို အမြန် စစ်ဆေးခြင်း
Pro Tip: Load average တန်ဖိုးသည် CPU core အရေအတွက်ထက် ကျော်လွန်နေပါက ဆာဗာ ဝန်ပိနေပါပြီ
vmstat 1 5CPU, Memory, Virtual Memory paging, Disk I/O နှင့် System interrupts များကို ၁ စက္ကန့်ခြား ၅ ကြိမ် အသေးစိတ် စစ်ဆေးခြင်း
ps aux --sort=-%mem | head -n 11ဆာဗာပေါ်တွင် RAM အများဆုံး စားသုံးနေသော ထိပ်သီး processes ၁၀ ခုကို စစ်ထုတ်ကြည့်ရှုခြင်း
Pro Tip: RAM ပြည့်ခါနီးအချိန်တွင် မည်သည့် app က memory leak ဖြစ်နေသည်ကို ချက်ချင်း ရှာဖွေနိုင်ပါသည်
ps aux --sort=-%cpu | head -n 11ဆာဗာပေါ်တွင် CPU အများဆုံး အသုံးပြုနေသော ထိပ်သီး processes ၁၀ ခုကို စစ်ထုတ်ကြည့်ရှုခြင်း
lscpuCPU architecture, Cores အရေအတွက်, Threads per core နှင့် Cache sizes အသေးစိတ် စစ်ဆေးခြင်း
Disk Space & Emergency Clean-up
Storage နှင့် Disk နေရာလွတ် ပြန်လည်ရယူခြင်း
df -hHard Disk partition အသီးသီး၏ အသုံးပြုထားမှု ရာခိုင်နှုန်းနှင့် ကျန်ရှိနေသော free space ကို GB ဖြင့် စစ်ဆေးခြင်း
df -iInode အသုံးပြုမှုကို စစ်ဆေးခြင်း (Disk နေရာ GB ကျန်သော်လည်း Inode ပြည့်ပါက ဖိုင်အသစ် ရေးမရတော့ပါ)
Pro Tip: Node modules သို့မဟုတ် session files သေးသေးလေးများ သန်းချီစုမိပါက Inode 100% ပြည့်သွားတတ်ပါသည်
sudo du -ahx / | sort -rh | head -n 10ဆာဗာတစ်ခုလုံးတွင် Disk space အများဆုံး ယူထားသော ဖိုင်နှင့် folder ကြီး ၁၀ ခုကို ရှာဖွေဖော်ထုတ်ခြင်း
sudo journalctl --vacuum-time=3d၃ ရက်ထက် ကျော်လွန်နေသော Systemd journal logs အဟောင်းများကို ရှင်းထုတ်ပြီး Disk space ကြီးမားစွာ ပြန်လည်ရယူခြင်း
Pro Tip: ထုတ်လုပ်မှုဆာဗာများတွင် GB ချီ နေရာယူထားသော log ဖိုင်များကို စက္ကန့်ပိုင်းအတွင်း ရှင်းလင်းပေးနိုင်ပါသည်
sudo find /var/log -type f -size +100M/var/log ထဲရှိ 100 Megabyte ထက် ကြီးမားနေသော log ဖိုင်ကြီးများကို လျင်မြန်စွာ ရှာဖွေခြင်း
sudo truncate -s 0 /var/log/nginx/access.log⚠️ Cautionဆာဗာ သို့မဟုတ် Nginx မရပ်တန့်စေဘဲ access.log ကို 0 bytes သို့ safe ရှင်းလင်းခြင်း (ဖိုင်မပျက်ပါ)
Pro Tip: rm ဖြင့် ဖျက်မိပါက Nginx file descriptor ဖွင့်ထားဆဲဖြစ်သဖြင့် disk space ချက်ချင်း ပြန်မရပါ၊ truncate သာ အသုံးပြုသင့်ပါသည်
sudo apt clean && sudo apt autoremove --purge -yDownload ရယူထားသော .deb installation package cache များနှင့် မလိုတော့သော dependency အဟောင်းများကို ရှင်းထုတ်ခြင်း
UFW Firewall & Security Defense
Firewall နှင့် Fail2ban လုံခြုံရေး စီမံခြင်း
sudo ufw status numberedFirewall ပေါ်ရှိ ဖွင့်ထားသော Port စည်းမျဉ်းများကို သက်ဆိုင်ရာ အမှတ်စဉ် (index number) ဖြင့် စစ်ဆေးခြင်း
sudo ufw allow 22/tcpSSH Port 22 ကို ဖွင့်လှစ်ခွင့်ပြုခြင်း (Firewall enable မလုပ်မီ မိမိကိုယ်ကို Lock out မဖြစ်စေရန် မဖြစ်မနေ ဦးစွာ run ရမည်)
Pro Tip: Port ပြောင်းထားပါက 22 အစား မိမိသတ်မှတ်ထားသော port number ကို အသုံးပြုပါ
sudo ufw allow 80/tcp && sudo ufw allow 443/tcpHTTP (Port 80) နှင့် HTTPS (Port 443) Web traffic များကို အများပြည်သူ ဝင်ရောက်နိုင်ရန် ဖွင့်လှစ်ပေးခြင်း
sudo ufw allow from <trusted_ip> to any port 22 proto tcpမိမိ၏ Trusted Static IP တစ်ခုတည်းမှသာ SSH Port သို့ ချိတ်ဆက်နိုင်စေရန် အမြင့်ဆုံးလုံခြုံရေး သတ်မှတ်ခြင်း
Pro Tip: Server ကို ပြင်ပစက်များမှ automated brute-force scans များ လုံးဝ မဝင်ရောက်နိုင်တော့ပါ
sudo ufw delete <rule_number>မလိုအပ်တော့သော Firewall rule ကို status numbered တွင် တွေ့ရှိရသော အမှတ်စဉ်ဖြင့် တိုက်ရိုက်ဖျက်ပစ်ခြင်း
sudo ufw reloadFirewall rule အပြောင်းအလဲများကို active connections မပြတ်တောက်စေဘဲ ချက်ချင်း ပြန်လည်အသက်သွင်းခြင်း
sudo fail2ban-client status sshdSSH သို့ password မှားယွင်းစွာ ကြိုးစားတိုက်ခိုက်မှုကြောင့် Fail2ban က လက်ရှိ Ban ထားသော IP address စာရင်းကို ကြည့်ရှုခြင်း
sudo fail2ban-client set sshd unbanip <banned_ip>မတော်တဆ Password မှားရိုက်မိ၍ Ban ခံလိုက်ရသော မိတ်ဆွေ သို့မဟုတ် client ၏ IP ကို ပြန်လည်ဖွင့်ပေးခြင်း (Unban)
Users, Permissions & Ownership
User နှင့် Permissions စီမံခန့်ခွဲမှု
sudo adduser <username>Production VPS တွင် root အစား နေ့စဉ်လုပ်ငန်းသုံးအတွက် standard non-root user အသစ် ဖန်တီးခြင်း
sudo usermod -aG sudo <username>ဖန်တီးထားသော သာမန် user အား administrative sudo လုပ်ပိုင်ခွင့် အဖွဲ့ထဲသို့ ထည့်သွင်းပေးခြင်း
sudo chown -R www-data:www-data /var/www/htmlWeb directory ဖိုင်များ၏ ပိုင်ဆိုင်ခွင့် (ownership) ကို Nginx/Apache Web Server process သို့ လွှဲပြောင်းပေးခြင်း
Pro Tip: File upload သို့မဟုတ် CMS permissions error တက်ပါက ဤ ownership ကို ဦးစွာ စစ်ဆေးပါ
sudo find /var/www/html -type d -exec chmod 755 {} +Web directory အတွင်းရှိ Folder အားလုံးကို Standard 755 (ပိုင်ရှင်ရေးခွင့်၊ အများဖတ်ခွင့်) သို့ တစ်ပြိုင်နက် သတ်မှတ်ခြင်း
sudo find /var/www/html -type f -exec chmod 644 {} +Web directory အတွင်းရှိ File အားလုံးကို Standard 644 (ပိုင်ရှင်ရေးခွင့်၊ အများဖတ်ခွင့်၊ run ခွင့်မရှိ) သို့ လုံခြုံစွာ သတ်မှတ်ခြင်း
Pro Tip: ဖိုင်များကို 777 လုံးဝ မပေးပါနှင့်။ 644 သည် အကောင်းဆုံးနှင့် အလုံခြုံဆုံး standard ဖြစ်ပါသည်
wလက်ရှိ ဆာဗာပေါ်တွင် မည်သည့် IP နှင့် မည်သည့် User များ Login ဝင်ရောက်နေပြီး အဘယ် command သုံးနေသည်ကို စစ်ဆေးခြင်း
sudo visudo/etc/sudoers ဖိုင်ကို syntax validation စစ်ဆေးပေးသော safe editor ဖြင့် ဖွင့်လှစ်ပြင်ဆင်ခြင်း
Pro Tip: Syntax အမှားပါပါက save လုပ်ခွင့်မပေးဘဲ သတိပေးသဖြင့် sudo access ဆုံးရှုံးမသွားစေရန် ကာကွယ်ပေးပါသည်
Nginx Web Server Operations
Nginx ဝဘ်ဆာဗာ စီမံခန့်ခွဲမှု
sudo nginx -tNginx configuration ဖိုင်များ syntax အမှားအယွင်း ရှိမရှိ စစ်ဆေးခြင်း (Reload မလုပ်မီ မဖြစ်မနေ run ရမည်)
Pro Tip: syntax is ok / test is successful ဟု ပြသမှသာ reload ပြုလုပ်ပါ
sudo systemctl reload nginxဝဘ်ဆိုက် visitors များ မပြတ်တောက်စေဘဲ Zero-Downtime ဖြင့် Nginx config အသစ်များကို အသက်သွင်းခြင်း
sudo systemctl status nginxNginx service လက်ရှိ active ဖြစ်မဖြစ်နှင့် uptime, worker process IDs များကို စစ်ဆေးခြင်း
sudo tail -f /var/log/nginx/error.logNginx တွင် ဖြစ်ပေါ်နေသော 502 Bad Gateway, 403 Forbidden စသည့် error များကို real-time အချိန်နှင့်တပြေးညီ စောင့်ကြည့်ခြင်း
sudo tail -f /var/log/nginx/access.log | grep -E ' " [45][0-9]{2} 'Nginx access log ထဲမှ 4xx (Client) နှင့် 5xx (Server) error status code တက်နေသော traffic များကိုသာ သီးသန့် စစ်ထုတ်ကြည့်ရှုခြင်း
sudo ln -s /etc/nginx/sites-available/<config> /etc/nginx/sites-enabled/sites-available ထဲရှိ Nginx server block config အား sites-enabled သို့ symbolic link ချိတ်၍ အသက်သွင်းခြင်း
sudo rm /etc/nginx/sites-enabled/<config>sites-enabled ထဲရှိ symbolic link ကို ဖြုတ်ပစ်ပြီး ဝဘ်ဆိုက်အား Nginx ပေါ်မှ ပိတ်သိမ်းခြင်း (မူရင်းဖိုင်မပျက်ပါ)
SSL / TLS & Let's Encrypt
SSL လက်မှတ် စီမံခန့်ခွဲမှု
sudo certbot --nginx -d <domain.com> -d <www.domain.com>Nginx ပေါ်တွင် အခမဲ့ HTTPS Let's Encrypt SSL Certificate ကို အလိုအလျောက် ရယူ၍ config တွဲချိတ်ခြင်း
Pro Tip: ဤ command မ run မီ ဒိုမိန်း၏ DNS A Record သည် ဆာဗာ IP သို့ ညွှန်ပြပြီးဖြစ်ရပါမည်
sudo certbot renew --dry-runSSL Certificate များ အလိုအလျောက် သက်တမ်းတိုးခြင်း (auto-renew) အဆင်ပြေပြေ အလုပ်လုပ်မလုပ် စမ်းသပ်စစ်ဆေးခြင်း
Pro Tip: cron job သို့မဟုတ် systemd timer မှန်ကန်စွာ အလုပ်လုပ်မလုပ် သိရှိရန် စစ်ဆေးပါ
sudo certbot certificatesဆာဗာပေါ်တွင် တပ်ဆင်ထားသော SSL Certificate အားလုံး၊ ဒိုမိန်းအမည်များနှင့် သက်တမ်းကုန်ဆုံးမည့် ရက်စွဲများကို စစ်ဆေးခြင်း
sudo certbot delete --cert-name <domain.com>အသုံးမပြုတော့သော ဒိုမိန်းတစ်ခု၏ SSL Certificate ဖိုင်များကို ဆာဗာထဲမှ သန့်ရှင်းစွာ ဖျက်ပစ်ခြင်း
Systemd Services & Journalctl Logs
Systemd Service နှင့် Logs စီမံခြင်း
sudo systemctl daemon-reload/etc/systemd/system/ ထဲတွင် service unit ဖိုင်အသစ် ရေးသားပြီးပါက systemd daemon အား အပြောင်းအလဲ သိရှိစေရန် reload လုပ်ခြင်း
sudo systemctl restart <service_name>သတ်မှတ်ထားသော backend service (ဥပမာ- api, bot, postgresql, nginx) ကို ပြန်လည်စတင်ခြင်း
sudo systemctl enable --now <service_name>ဆာဗာ reboot ဖြစ်ချိန်တွင် အလိုအလျောက် ပွင့်စေရန် enable ပြုလုပ်ပြီး လက်ရှိအချိန်တွင်လည်း ချက်ချင်း စတင်ခြင်း
Pro Tip: --now flag ထည့်သွင်းခြင်းဖြင့် start နှင့် enable နှစ်ဆင့် run စရာ မလိုတော့ပါ
sudo journalctl -u <service_name> -f -n 100Service ၏ နောက်ဆုံး log အကြောင်း ၁၀၀ ကို timestamp များနှင့်တကွ real-time live follow လုပ်၍ စောင့်ကြည့်ခြင်း
systemctl --failedစတင်ရန် ကြိုးစားသော်လည်း crash ဖြစ်၍ ရပ်တန့်နေသော systemd service များ စာရင်းကို အမြန် စစ်ဆေးခြင်း
sudo journalctl -xeu <service_name>Service crash ဖြစ်ရသည့် အကြောင်းရင်း (stack trace, error message) အသေးစိတ်ကို explanation အပြည့်အစုံဖြင့် ဖတ်ရှုခြင်း
Node.js & PM2 Process Management
Node.js & PM2 ဝန်ဆောင်မှုများ
pm2 listPM2 ဖြင့် စီမံခန့်ခွဲထားသော Node.js apps များ၏ ID, status, restart count, CPU နှင့် Memory စာရင်းကို ကြည့်ရှုခြင်း
pm2 monitTerminal ပေါ်တွင် real-time visual monitor ဖြင့် Node.js process များ၏ CPU, Event loop နှင့် Memory ကို စောင့်ကြည့်ခြင်း
pm2 start server.js --name "<app_name>" -i maxServer ၏ CPU Cores အားလုံးကို အပြည့်အဝ အသုံးပြု၍ Node.js app ကို Cluster Mode ဖြင့် စတင် run ခြင်း
Pro Tip: Single core ပေါ်တွင်သာ မ run ဘဲ multiprocessor throughput ကို အများဆုံး ရရှိစေပါသည်
pm2 reload all --update-envဝဘ်ဆိုက်မရပ်တန့်စေဘဲ Zero-Downtime ဖြင့် environment variables အသစ်များနှင့်အတူ cluster processes များကို တစ်လှည့်စီ reload လုပ်ခြင်း
pm2 save && pm2 startupလက်ရှိ run နေသော process စာရင်းကို သိမ်းဆည်းပြီး ဆာဗာ reboot ဖြစ်သွားပါက auto ပြန်ပွင့်စေမည့် systemd script ထုတ်ယူခြင်း
Pro Tip: ဆာဗာ crash ဖြစ်၍ restart ကျသွားသော်လည်း ဝဘ်ဆိုက် အလိုအလျောက် ပြန်ပွင့်လာစေပါသည်
pm2 logs <app_name> --lines 100App ၏ နောက်ဆုံး standard output နှင့် error log အကြောင်း ၁၀၀ ကို စစ်ဆေးခြင်း
pm2 flushPM2 log ဖိုင်များ အဆမတန် ကြီးမားနေပါက ရှင်းထုတ်ပြီး Disk space ပြန်လည် ရယူခြင်း
Python & FastAPI / Django Services
Python ဝဘ်အက်ပလီကေးရှင်းများ
python3 -m venv venvSystem packages များနှင့် မရောထွေးစေရန် သီးခြား သန့်ရှင်းသော Python Virtual Environment တစ်ခု တည်ဆောက်ခြင်း
source venv/bin/activateဖန်တီးထားသော Virtual Environment ထဲသို့ ဝင်ရောက် activate ပြုလုပ်ခြင်း
pip install --no-cache-dir -r requirements.txtVPS ပေါ်တွင် Disk cache နေရာ မစားသုံးစေဘဲ လိုအပ်သော Python libraries အားလုံးကို requirements.txt မှ install ပြုလုပ်ခြင်း
gunicorn -w 4 -k uvicorn.workers.UvicornWorker main:app --bind 0.0.0.0:8000Gunicorn master process နှင့် Uvicorn async workers ၄ ခုဖြင့် FastAPI app ကို production grade စမ်းသပ် run ခြင်း
ps aux | grep python3ဆာဗာပေါ်တွင် လက်ရှိ run နေသော Python backend processes များနှင့် script များကို စစ်ဆေးခြင်း
Docker & Container Orchestration
Docker ကွန်တိန်နာ အမြန်သုံး
docker psလက်ရှိ active ဖြစ်ပြီး run နေသော Docker containers စာရင်း၊ Container IDs နှင့် Port mappings ကို ကြည့်ရှုခြင်း
docker ps -aဆာဗာပေါ်တွင် ရပ်တန့်နေသော သို့မဟုတ် crash ဖြစ်သွားသော container အားလုံး၏ exit code များကို စစ်ဆေးခြင်း
docker compose up -ddocker-compose.yml ပါ multi-container stack အားလုံးကို background daemon အဖြစ် တစ်ပြိုင်နက် စတင်ခြင်း
docker compose up -d --buildSource code အပြောင်းအလဲများကို Dockerfile မှ အသစ် rebuild လုပ်ပြီး container stack အား zero-downtime နီးပါး update ပြုလုပ်ခြင်း
docker compose downStack အတွင်းရှိ containers နှင့် networks များကို ဘေးကင်းစွာ ရပ်တန့်ပြီး ဖျက်ပစ်ခြင်း (Volumes ထဲရှိ data များ မပျက်ပါ)
docker logs -f --tail 100 <container_name>Container တစ်ခု၏ log များကို နောက်ဆုံး အကြောင်း ၁၀၀ မှစတင်၍ live follow စောင့်ကြည့်ခြင်း
docker exec -it <container_name> shRun နေသော Docker container အတွင်းသို့ interactive terminal shell ဖြင့် ဝင်ရောက်အသုံးပြုခြင်း
Pro Tip: Ubuntu/Debian container ဖြစ်ပါက sh အစား bash ကို အသုံးပြုနိုင်ပါသည်
docker system dfDocker က disk space မည်မျှ ယူထားသည်ကို Images, Containers, Local Volumes နှင့် Build Cache အလိုက် အသေးစိတ် စစ်ဆေးခြင်း
docker system prune -a --volumes -f⚠️ Cautionအသုံးမလိုတော့သော container, dangling image, unused network နှင့် unused volumes များကို nuclear ရှင်းထုတ်ပြီး Disk space ပြန်လည် ရယူခြင်း
Pro Tip: သတိပြုရန်: Database volume များ attach မလုပ်ထားပါက ဖျက်ချမိနိုင်သဖြင့် အရေးကြီး data များ backup ယူပြီးမှသာ run ပါ
Production Databases (Postgres, MySQL, Redis)
ဒေတာဘေ့စ် စီမံခန့်ခွဲမှုနှင့် Backup
sudo -u postgres psqlPostgreSQL superuser terminal console သို့ ချက်ချင်း ဝင်ရောက်ခြင်း
pg_dump -U <user> -d <database> -F c -b -v -f backup.dumpPostgreSQL database တစ်ခုလုံးကို compressed custom format ဖြင့် အပြည့်အဝ backup ထုတ်ယူခြင်း (Fast & Reliable)
Pro Tip: -F c format ဖြင့် dump လုပ်ထားပါက ပြန် restore လုပ်ရာတွင် pg_restore ဖြင့် thread များခွဲ၍ အလွန်လျင်မြန်စွာ ပြန်သွင်းနိုင်ပါသည်
pg_restore -U <user> -d <database> -v backup.dumpCompressed backup.dump ဖိုင်မှ data များကို PostgreSQL database အသစ်ထဲသို့ restore ပြန်လည် ထည့်သွင်းခြင်း
mysqldump -u <user> -p <database> > backup.sqlMySQL / MariaDB database ကို standard SQL text file အဖြစ် dump ထုတ်ယူ၍ backup ပြုလုပ်ခြင်း
mysql -u <user> -p <database> < backup.sqlSQL backup ဖိုင်မှ data များကို MySQL database ထဲသို့ restore ပြန်လည် import ထည့်သွင်းခြင်း
redis-cli pingRedis in-memory cache server အလုပ်လုပ်နေခြင်း ရှိမရှိ စစ်ဆေးခြင်း (PONG ဟု ပြန်ကြားရမည်)
redis-cli info memoryRedis cache memory စားသုံးမှု၊ peak memory နှင့် fragmentation ratio များကို စစ်ဆေးခြင်း
Networking, Ports & Domain Lookup
Ports နှင့် နက်ဝပ် စစ်ဆေးခြင်း
sudo ss -tulpnဆာဗာပေါ်တွင် နားထောင် (LISTEN) နေသော TCP/UDP Ports အားလုံးနှင့် သက်ဆိုင်ရာ Process PIDs များကို စစ်ဆေးခြင်း
Pro Tip: netstat ထက် ပိုမိုမြန်ဆန်ပြီး modern Linux kernel တွင် standard အဖြစ် အသုံးပြုပါသည်
sudo lsof -i :<port>သတ်မှတ်ထားသော Port (ဥပမာ- 3000, 8080) ကို မည်သည့် Process က အသုံးပြု ပိတ်ဆို့နေသည်ကို စစ်ဆေးဖော်ထုတ်ခြင်း
sudo fuser -k <port>/tcp⚠️ Cautionသတ်မှတ်ထားသော Port ပေါ်တွင် ပိတ်ဆို့နေသော unresponsive process ကို ချက်ချင်း kill သတ်ပစ်ခြင်း
Pro Tip: Port conflict ဖြစ်ပြီး application start မရဖြစ်နေချိန်တွင် အလွန် အသုံးဝင်ပါသည်
curl -Iv https://<domain>ဝဘ်ဆိုက်၏ HTTP Response Status Code, Server Header, SSL Handshake နှင့် Latency ကို အသေးစိတ် စစ်ဆေးခြင်း
dig +short A <domain>ဒိုမိန်းတစ်ခု၏ လက်ရှိချိတ်ဆက်ထားသော IPv4 Address ကို DNS cache အမြန် စစ်ဆေးကြည့်ရှုခြင်း
nc -zv <server_ip> <port>Netcat အသုံးပြု၍ အဝေးရှိ server သို့မဟုတ် port သို့ outbound connection ချိတ်ဆက်၍ ရမရ စမ်းသပ်စစ်ဆေးခြင်း
File Transfers, Archives & Sync
ဖိုင်ပို့ဆောင်ခြင်းနှင့် Backup ချုံ့ယူခြင်း
tar -czvf <archive_name>.tar.gz /path/to/folderFolder တစ်ခုလုံးကို gzip algorithm ဖြင့် ကျစ်လစ်စွာ ချုံ့ယူ၍ .tar.gz archive backup ပြုလုပ်ခြင်း
tar -xzvf <archive_name>.tar.gz -C /target/folder.tar.gz archive ဖိုင်ကို သတ်မှတ်ထားသော target destination folder သို့ ဖြည်ချ extract ပြုလုပ်ခြင်း
rsync -avzP -e "ssh -p <port>" /local/dir/ <user>@<server_ip>:/remote/dir/SSH မှတစ်ဆင့် ဖိုင်များကို transfer resume support, compression နှင့် progress bar ဖြင့် အလျင်မြန်ဆုံး sync ပို့ဆောင်ခြင်း
Pro Tip: SCP ထက် သာလွန်ပြီး ပြောင်းလဲသွားသော ဖိုင်များကိုသာ incremental ပို့ဆောင်ပေးပါသည်
scp -P <port> <local_file> <user>@<server_ip>:/var/www/ဖိုင်တစ်ခုတည်းကို SSH ချိတ်ဆက်မှုမှတစ်ဆင့် ဆာဗာပေါ်သို့ လုံခြုံစွာ ကူးယူပို့ဆောင်ခြင်း
unzip <file>.zip -d /target/folderStandard .zip ဖိုင်ကို သတ်မှတ်ထားသော directory သို့ ဖြည်ချခြင်း
Emergency Incident & Crash Recovery
အရေးပေါ် ဆာဗာ ပြန်လည်ကုစားခြင်း
curl -Iv http://127.0.0.1:<port>Nginx reverse proxy ကို ကျော်ပြီး backend app ကို localhost မှ တိုက်ရိုက် test စစ်ဆေးခြင်း (502 Bad Gateway ရှာဖွေရန်)
Pro Tip: 502 error တက်ပါက ဤ command ဖြင့် စစ်ဆေးခြင်းဖြင့် backend app သေနေခြင်း ဟုတ်မဟုတ် ချက်ချင်း သိနိုင်ပါသည်
sudo dmesg -T | grep -E -i 'killed process|out of memory'Linux Kernel ၏ OOM Killer က RAM ပြည့်သွား၍ မည်သည့် application process ကို သတ်ပစ်ခဲ့သည်ကို အချိန်နှင့်တကွ စစ်ဆေးခြင်း
Pro Tip: App ရုတ်တရက် restart ဖြစ်သွားပါက OOM Killer ကြောင့် ဟုတ်မဟုတ် ဤနေရာတွင် အဖြေရှာပါ
sudo swapon --showလက်ရှိ active ဖြစ်နေသော Swap file/partition နှင့် အသုံးပြုနေမှု ပမာဏကို စစ်ဆေးခြင်း
sync && echo 3 | sudo tee /proc/sys/vm/drop_caches⚠️ CautionLinux PageCache, dentries နှင့် inodes cache များကို memory ထဲမှ ချက်ချင်း ရှင်းထုတ်ပြီး RAM ပြန်လည်ရယူခြင်း
Pro Tip: အရေးပေါ် RAM ပြည့်နေချိန်တွင်သာ ယာယီသုံးရန်ဖြစ်ပြီး ပုံမှန်အချိန်တွင် run ရန် မလိုပါ
kill -15 <PID>Process တစ်ခုအား မပျက်စီးစေဘဲ database connection များကို သပ်ရပ်စွာ ပိတ်သိမ်းရန် Graceful Shutdown (SIGTERM) ပို့ခြင်း
Pro Tip: အမြဲတမ်း ဦးစွာ kill -15 ကို သုံးပါ၊ kill -9 ကို နောက်ဆုံးမှသာ သုံးပါ
kill -9 <PID>⚠️ Cautionလုံးဝ တုံ့ပြန်မှု မရှိတော့သော Zombie process ကို Kernel မှ ချက်ချင်း အတင်းအဓမ္မ သတ်ပစ်ခြင်း (SIGKILL)
Pro Tip: Force kill ဖြစ်သဖြင့် open files သို့မဟုတ် transactions များ မပြီးပြတ်ဘဲ ကျန်ခဲ့နိုင်ပါသည်
git fetch origin && git reset --hard origin/main⚠️ Cautionဆာဗာပေါ်တွင် မတော်တဆ ပြင်ဆင်မိသော ဖိုင်အပြောင်းအလဲများကို ပယ်ဖျက်ပြီး GitHub main branch အခြေအနေအတိုင်း အတိအကျ sync ပြန်လုပ်ခြင်း
Pro Tip: ဆာဗာပေါ်တွင် manual ပြင်ဆင်ထားသမျှ uncommitted code များ အားလုံး ပျက်ပြယ်သွားပါမည်