Homelab

ตั้งค่า Ubuntu Server

โน๊ตนี้คือ commands ที่มักจะใช้บ่อย ๆ เมื่อต้อง setup ubuntu server (20.04, 22.04)

Introduction

รวม command ที่ต้องใช้บ่อย ๆ เมื่อมีการ Setup เครื่อง Ubuntu ใหม่ (Version 20, 22, 24)

หมวดหมู่การตั้งค่าพื้นฐาน

Update Packages ต่าง ๆ ที่ติดตั้งมาใน OS ให้เป็น Version ล่าสุด

sudo apt update && sudo apt upgrade -y

แก้ไข timezone ให้เป็น Asia/Bangkok

sudo timedatectl set-timezone Asia/Bangkok

ติดตั้ง Packages ที่สำคัญสำหรับการพัฒนา (Development) โดยภายใน Build Essential จะมีการรวมเอา Packages ที่สำคัญเอาไว้เช่น gcc, c++, make, lib6-dev และอื่น ๆ อีกมากมาย

sudo apt install build-essential

แก้ไข Hostname

sudo hostnamectl set-hostname <hostname>

ปิดการใช้งาน Cloud-init network

sudo nano  /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg

# เอาไปใส่ในไฟล์
network: {config: disabled}

ขั้นตอนการติดตั้ง docker ใน version daemon

ติดตั้ง curl สำหรับการเรียกใช้งาน Script

sudo apt update
sudo apt install curl -y

ติดตั้งโดยใช้ script จาก get.docker.com ซึ่งจะช่วยในการติดตั้ง docker แบบง่ายมาก ๆ

script นี้จำเป็นต้องใช้ root หรือ sudo ในการทำงานนะครับ

cd /tmp
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

หากต้องการรัน docker โดยไม่ต้องรัน sudo นำหน้าสามารถเพิ่ม user ดังกล่าวเข้าไปใน group docker ได้ครับ

# run docker without sudo
sudo gpasswd -a $USER docker
sudo service docker restart

ทดสอบเรียกใช้งาน

docker --version

ติดตั้ง helm

Credit: https://helm.sh/docs/intro/install/#from-script

cd /tmp
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh

ติดตั้ง ZSH + P10k Configure เพื่อให้ใช้งาน terminal ได้ง่ายยิ่งขึ้น

sudo apt install curl wget git zsh -y

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

ติดตั้ง plugins เพิ่มเติมโดยแนะนำเป็น zsh-syntax-highlighting เพื่อช่วยในการ highlight command และ zsh-autosuggestions ซึ่งจะเป็นการนำเอา history มาแสดงให้ขณะพิมพ์ command

# Install plugins
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

แก้ไข .zshrc file เพื่อทำการเพิ่ม plugins เข้าไป

nano ~/.zshrc

# Update plugins
plugins=(
    git
    zsh-syntax-highlighting # <- Add
    zsh-autosuggestions     # <- Add
)

จากนั้น reload .zshrc file เพื่อทำการ reload การตั้งค่า

source ~/.zshrc

ลง P10K เพิ่มเพื่อทำให้ terminal ดูสวยงามมากยิ่งขึ้น

git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

จากนั้นแก้ไข ZSH_THEME ให้เป็น powerlevel10k/powerlevel10k เพื่อ load theme ดังกล่าวเข้าไป

# Update .zshrc file
nano ~/.zshrc

# Update Theme
ZSH_THEME="powerlevel10k/powerlevel10k"

# Reload
source ~/.zshrc

ติดตั้ง NodeJS (v.22)

curl -sL https://deb.nodesource.com/setup_22.x -o /tmp/nodesource_setup.sh
sudo bash /tmp/nodesource_setup.sh
sudo apt install nodejs

# Verify
node -v

ติดตั้ง yarn เพิ่มเติม

# Install yarn
sudo npm install -g yarn

# Verify
yarn --version

Related Articles

Setup Uptime Kuma
Homelab

Setup Uptime Kuma

โน๊ตนี้คือ วิธีการ setup uptime kuma แบบไม่ใช้ docker
วิธีการติดตั้ง Ubuntu Version Pro แบบฟรี
Homelab

วิธีการติดตั้ง Ubuntu Version Pro แบบฟรี

เราสามารถขอ Ubuntu Pro มาใช้งานในแบบ personal use ได้ฟรี !!
ผมย้ายจาก Pihole & Adguard มาใช้ NextDNS
Homelab

ผมย้ายจาก Pihole & Adguard มาใช้ NextDNS

การมี DNS ที่ช่วยในการ Block โฆษณาหรือการ Tracking ในยุคสมัยนี้ถือว่าเป็นสิ่งที่ควรจะมี