Ubuntu Linux Install

1. Ubuntu Linux Install

Download and install the lastest Ubuntu in a Windows Hyper-V VM or on physical hardware.

2. Post Install

2.1. Install Net Tools

sudo apt install net-tools

2.2. Install SSH server

  1. Install

    sudo apt -y install openssh-server
  2. Now you can connect remotely via ssh and continue with the remaining steps.

2.3. WiFi

2.3.1. WiFi Test

  1. Run

    Run
    sudo lshw -C network
    Sample
      *-network UNCLAIMED
           description: Network controller
           product: Wireless 8265 / 8275
           vendor: Intel Corporation
           physical id: 0
           bus info: pci@0000:06:00.0
           version: 78
           width: 64 bits
           clock: 33MHz
           capabilities: pm msi pciexpress cap_list
           configuration: latency=0
           resources: memory:dc000000-dc001fff

2.3.2. WiFi Fix

  1. Get Linux kernel version

    Run
    uname -r
    Sample
    6.8.0-51-generic
  2. Run

    Run
    sudo apt reinstall  linux-modules-extra-6.8.0-51-generic

2.4. Set the Time Zone

  1. View the current time zone

    timedatectl
    Example
                   Local time: Sun 2023-05-21 04:20:25 SST
               Universal time: Sun 2023-05-21 15:20:25 UTC
                     RTC time: Sun 2023-05-21 15:20:25
                    Time zone: Pacific/Pago_Pago (SST, -1100)
    System clock synchronized: yes
                  NTP service: active
              RTC in local TZ: no
  2. If the time and timezone are already correct, then skip over this section.

  3. View available Timezones

    timedatectl list-timezones | grep New_York
    Example US Timezones
    America/New_York
  4. Set the Timezone

    sudo timedatectl set-timezone America/New_York
  5. Confirm new Timezone

    timedatectl
    New Timezone
                   Local time: Sun 2024-03-31 20:19:09 EDT
               Universal time: Mon 2024-04-01 00:19:09 UTC
                     RTC time: Mon 2024-04-01 00:19:09
                    Time zone: America/New_York (EDT, -0400)
    System clock synchronized: yes
                  NTP service: active
              RTC in local TZ: no

2.5. Perform Updates and Upgrades

This will take a few minutes to complete…​
  1. Updates and Upgrades

    sudo apt update -y && sudo apt upgrade -y
  2. Reboot

    sudo reboot now

2.6. Install iotop

  1. Install

    sudo apt install iotop
    Like the top command but for disk activity, disk io

2.7. Install dnslookup

  1. Install

    sudo snap install dnslookup

2.8. Install NetCat

  1. Install

    sudo apt install -y netcat

2.9. Install Nmap

  1. Install

    sudo apt install -y nmap

2.10. Install Curl

  1. Install

    sudo apt update && sudo snap install curl

2.11. Install IPMI Tools

  1. Install IPMI packages

    sudo apt-get install -y ipmitool ipmiutil

2.12. Install Samba

2.12.1. Install Samba

  1. Install

    sudo apt-get install samba -y
    sudo apt-get install keyutils
    sudo apt-get install cifs-utils
    sudo apt install smbclient
  2. Start Samba

    sudo systemctl enable --now smbd
  3. Create new Group for Samba

    sudo addgroup sambagroup
  4. Add User into new Group for Samba

    1. Add user to group

      sudo usermod -aG sambagroup mattosd
    2. Confirm User added to new group

      id mattosd
      Example
      uid=1000(mattosd) gid=1000(mattosd) groups=1000(mattosd),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),122(lpadmin),134(lxd),135(sambashare),1001(sambagroup)

2.12.2. Add User

  1. Configure user name & password

    sudo smbpasswd -a mattosd (1)(2)
    1 Must be an actual local account name
    2 This password is for Samba use only - it can be different from the account’s password but if it is the same as the network password, then credentials will not need to be provided for the connection.
  2. Enable User

    sudo smbpasswd -e mattosd

2.13. Install ZFS

  1. Install

    sudo apt update && sudo apt install -y zfsutils-linux
  2. Confirm

    zfs --version
    example
    zfs-2.1.5-1ubuntu6~22.04.4
    zfs-kmod-2.2.0-0ubuntu1~23.10.2

2.14. Install GPU Drivers

2.14.1. NVidia

  1. Add the graphics drivers PPA

    sudo apt update && sudo add-apt-repository ppa:graphics-drivers/ppa
  2. Identify graphics card and list suggested drivers

    ubuntu-drivers devices
    Sample
    == /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
    modalias : pci:v000010DEd00001E07sv00003842sd00002382bc03sc00i00
    vendor   : NVIDIA Corporation
    model    : TU102 [GeForce RTX 2080 Ti Rev. A]
    driver   : nvidia-driver-418-server - distro non-free
    driver   : nvidia-driver-470-server - distro non-free
    driver   : nvidia-driver-535 - distro non-free recommended
    driver   : nvidia-driver-545 - distro non-free
    driver   : nvidia-driver-450-server - distro non-free
    driver   : nvidia-driver-470 - distro non-free
    driver   : nvidia-driver-535-server - distro non-free
    driver   : nvidia-driver-545-open - distro non-free
    driver   : nvidia-driver-535-server-open - distro non-free
    driver   : nvidia-driver-535-open - distro non-free
    driver   : xserver-xorg-video-nouveau - distro free builtin
  3. Install

    Autoinstall
    sudo ubuntu-drivers autoinstall
    Specific driver
    sudo apt install nvidia-driver-xxx
  4. Reboot

    sudo reboot now

2.15. Install GPU Utils

2.15.1. Install GPU Stat

  1. Install

    sudo apt update && sudo apt -y install gpustat

2.16. Install Docker or Podman

ONLY INSTALL ONE OR THE OTHER - A HOST CANNOT RUN BOTH!

2.16.1. Install Podman

  1. About Podman

  2. Install Podman

    sudo apt update && sudo apt -y install podman podman-compose

2.16.2. Install Docker

  1. Install Docker

    sudo apt update && sudo apt -y install docker.io
  2. Add User

    sudo usermod -aG docker $USER
  3. Activate the changes to groups

    newgrp docker
  4. Verify the ability to run docker commands without sudo

    docker run hello-world

2.16.3. Install Docker Compose

  1. Official documentation.

  2. Install the apt Repository

    1. Add Docker’s official GPG key

      sudo apt-get update
      sudo apt-get install ca-certificates curl
      sudo install -m 0755 -d /etc/apt/keyrings
      sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
      sudo chmod a+r /etc/apt/keyrings/docker.asc
    2. Add the repository to Apt sources

      echo \
        "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
        $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
        sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
      sudo apt-get update
  3. Install the Docker packages.

    1. Install

      sudo apt-get -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
    2. Start the docker engine

      sudo service docker start
    3. Confirm Docker is working.

      sudo docker run hello-world
  4. Run docker without sudo command

    1. Setup

      sudo groupadd docker
      sudo usermod -aG docker $USER
      newgrp docker
    2. Confirm Docker is working without the sudo command.

      docker run hello-world
  5. Configure Docker to start on boot with systemd

    On Debian and Ubuntu, the Docker service starts on boot by default
    sudo systemctl enable docker.service
    sudo systemctl enable containerd.service
  6. Configure log rotation.

    1. Create or edit the following file:

      File name
      /etc/docker/daemon.json
      Content
      {
        "log-driver": "json-file",
        "log-opts": {
          "max-size": "10m",
          "max-file": "3"
        }
      }
  7. Install the Plugin

    sudo apt-get install docker-compose-plugin

2.16.4. Install Docker Compose Standalone

Not Recommended!
  1. Official documentation.

  2. Run

    curl -SL https://github.com/docker/compose/releases/download/v2.32.2/docker-compose-linux-x86_64 -o ./docker-compose
  3. Move the file

    sudo mv ./docker-compose /usr/local/bin/docker-compose
  4. Apply executable permissions to the standalone binary in the target path for the installation

    sudo chmod +x /usr/local/bin/docker-compose

    If the command can’t be found, create this softlink

    sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

2.17. Install npx

  • The primary purpose of npx is to execute packages. Without installing, it can run any package you want from the npm registry. This is particularly useful when you want to run the package only once and want to avoid installing it globally or locally.

    1. Install npm

      sudo apt install -y npm

2.18. Install git

sudo apt -y install git

2.19. Install Visual Studio Code

  1. Install

    • Original install doc can be referenced here.

    • If Snap is installed then:

      sudo snap install --classic code

2.20. Install Cockpit

2.21. Install Browsers

2.21.1. Install Brave

  1. Get Brave

    sudo apt install curl
    sudo curl -fsSLo /usr/share/keyrings/brave-browser-archive-keyring.gpg https://brave-browser-apt-release.s3.brave.com/brave-browser-archive-keyring.gpg
    echo "deb [signed-by=/usr/share/keyrings/brave-browser-archive-keyring.gpg] https://brave-browser-apt-release.s3.brave.com/ stable main"|sudo tee /etc/apt/sources.list.d/brave-browser-release.list
    sudo apt update
  2. Install Brave

    sudo apt install brave-browser -y

2.21.2. Install Microsoft Edge

  1. Get Edge

    curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
    sudo install -o root -g root -m 644 microsoft.gpg /etc/apt/trusted.gpg.d/
    sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/edge stable main" > /etc/apt/sources.list.d/microsoft-edge-dev.list'
    sudo rm microsoft.gpg
  2. Install Edge

    sudo apt update && sudo apt install microsoft-edge-stable

3. Resize Swap File

  1. Check size and confirm swap type = file

    swapon --show
    Example with a 1GB swap file
    NAME      TYPE   SIZE   USED PRIO
    /swapfile file 923.2M 245.5M   -2
    Partition Type
    However if type = partition, then a file partioning app will need to be used instead.
    Example with a 2GB partition based swap
    NAME      TYPE      SIZE USED PRIO
    /dev/sde2 partition   2G 1.5G   -2  (1)
    1 The second partition on disk e is configured as a temp partition
  2. Turn off swap

    sudo swapoff /swapfile
    This may take some time and will not produce any progress related output.
  3. Allocate a new swap file

    Allocate a 4GB file
    sudo fallocate -l 4G /swapfile
  4. Mark this file as the swapfile

    sudo mkswap /swapfile
    Example
    sudo mkswap /swapfile
    mkswap: /swapfile: warning: wiping old swap signature.
    Setting up swapspace version 1, size = 4 GiB (4294963200 bytes)
  5. Enable the swapfile

    sudo swapon /swapfile
  6. Confirm swap is re-enabled with new size

    swapon --show
    Example with new 4GB swapfile
    swapon --show
    NAME      TYPE SIZE   USED PRIO
    /swapfile file   4G 737.7M   -2