Prerequisites

  • Monitor
  • HDMI cable to connect to monitor
  • Keyboard
  • USB drive with at least 8GB capacity
  • Network cable

Installing the System

  • Download the image from Ubuntu or Debian official website
  • Prepare a USB drive with at least 8GB capacity, install Etcher, and flash the Ubuntu image to the USB drive following the instructions
  • Insert the USB drive into the PC, boot, and repeatedly press F7 (different motherboards use different keys) to enter BIOS
  • Allocate the entire disk to Ubuntu. If you don’t plan to tinker later, you can skip LVM Group, which will result in just two partitions: / and /boot/efi
  • Follow the remaining prompts and wait for the system to start.

Ubuntu 24.04

  • Usually after installation, the system will connect to WiFi via DHCP, but I prefer to use static IP addresses and connect one network port to the router. So I need to change the default IP address.

  • First, check the current address information with:

    ip addr
    
  • I plan to change the IP address of enp0s1 to 192.168.2.66, with the default gateway being the main router 192.168.2.1. Edit the file 01-netcfg.yaml, or create it if it doesn’t exist:

    network:
      version: 2
      renderer: networkd
      ethernets:
        enp1s0:
          dhcp4: no
          addresses:
            - 192.168.2.66/24
          routes:
            - to: default
              via: 192.168.2.1
          nameservers:
            addresses:
              - 8.8.8.8
              - 8.8.4.4
    
  • If you get a “Permission too open” message, change permissions:

    sudo chmod 600 /etc/netplan/01-netcfg.yaml
    
  • Apply Netplan configuration:

    sudo netplan apply
    
  • Restart network service (optional):

    sudo systemctl restart systemd-networkd
    
  • Insert network cable and verify the configuration:

    ip addr
    

Debian 12

  • I recently tried Debian 13. Although it’s planning to gradually deprecate the interfaces (ifupdown) network management method, I found that Debian 13 Server still uses it by default.

  • First, check the network interface name:

    ip addr
    

    Mine is ens18.

  • Edit the file /etc/network/interfaces:

    # This file describes the network interfaces available on your system
    # and how to activate them. For more information, see interfaces(5).
    
    source /etc/network/interfaces.d/*
    
    # The loopback network interface
    auto lo
    iface lo inet loopback
    
    # The primary network interface
    auto ens18
    iface ens18 inet static
            address 192.168.2.111/24   # Your machine's IP address
            network 192.168.2.0
            broadcast 192.168.2.255
            gateway 192.168.2.1
            dns-nameservers 8.8.8.8
    
  • If your Linux is connected via WiFi, use the same approach:

    # This file describes the network interfaces available on your system
    # and how to activate them. For more information, see interfaces(5).
    
    source /etc/network/interfaces.d/*
    
    # The loopback network interface
    auto lo
    iface lo inet loopback
    
    # The primary network interface
    auto wlp2s0
    allow-hotplug wlp2s0
    iface wlp2s0 inet static
            address 192.168.2.111    		# Your machine's IP address
            netmask 255.255.255.0			# Netmask
            gateway 192.168.2.1		 		# Gateway
            dns-nameservers 192.168.2.1		# DNS
            wpa-ssid YourWiFiSSID
            wpa-psk  YourWiFiPassword
    
  • Restart the network service:

    sudo systemctl restart networking.service
    
  • Since the default is DHCP when starting, the system generates default DNS servers from the router in /etc/resolv.conf. But after changing to static, this file will be cleared after reboot. So we need to lock this file:

    su -
    chattr +i /etc/resolv.conf
    

    Or install the resolvconf package, which will collect DNS information from interfaces and sync to the resolv.conf file. Both approaches work, but locking is simpler and more direct. This way the network won’t go down after reboot.

Other Configuration

Here are some other basic configurations:

  • Install sudo:

    su root
    apt install sudo
    
    # Add user to sudo group
    sudo usermod -aG sudo username
    
    # Password-free sudo
    sudo visudo
    # Modify the file content
    %sudo ALL=(ALL:ALL) NOPASSWD: ALL
    
  • Install vim:

    sudo apt install vim
    
  • Change timezone:

    sudo timedatectl set-timezone America/Toronto
    
  • Install OpenSSH:

    sudo apt update
    sudo apt install openssh-server
    
  • Install Docker. See: Creating OpenWrt as a Docker Image | Kunyang’s Blog

  • Switch to zsh:

    • Install:

      sudo apt update
      sudo apt install zsh git curl -y
      sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
      
      # Auto-suggestion plugin
      git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
      
      # Syntax highlighting plugin
      git clone https://github.com/zsh-users/zsh-syntax-highlighting ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting
      
    • Configure:

      cat > ~/.zshrc << 'EOF'
      export ZSH="$HOME/.oh-my-zsh"
      # ZSH_THEME="robbyrussell"
      ZSH_THEME="philips"
      
      plugins=(
        git
        docker
        docker-compose
        zsh-autosuggestions
        zsh-syntax-highlighting
      )
      
      source $ZSH/oh-my-zsh.sh
      
      # Common aliases
      alias ll='ls -alF'
      alias la='ls -A'
      alias l='ls -CF'
      alias grep='grep --color=auto'
      EOF
      
    • Refresh:

      source ~/.zshrc