Skip to content

Instantly share code, notes, and snippets.

@jordanluyke
Last active April 20, 2025 23:15
Show Gist options
  • Save jordanluyke/0118cb3d83c7b1f6659f1b4c470920d7 to your computer and use it in GitHub Desktop.
Save jordanluyke/0118cb3d83c7b1f6659f1b4c470920d7 to your computer and use it in GitHub Desktop.
Ubuntu Setup

Ubuntu Setup

Server

  • Download

  • Image:

    sudo fdisk -l
    

    Ubuntu:

    sudo dd if=ubuntu-server.iso of=/dev/sda bs=8M conv=fdatasync status=progress
    

    Fedora:

    sudo unxz --keep Fedora-Server-38-1.6.aarch64.raw.xz
    sudo dd if=Fedora-Server-38-1.6.aarch64.raw of=/dev/sda bs=8M conv=fdatasync status=progress
    
  • Timezone

    sudo timedatectl set-timezone America/Denver
    
  • Disable sleep

    systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
    
  • Add user

    sudo adduser username
    sudo usermod -aG sudo username
    sudo vi /etc/hostname
    
  • Resize LVM

    sudo lvdisplay
    sudo lvm lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
    sudo resize2fs -p /dev/mapper/ubuntu--vg-ubuntu--lv
    
  • Network: /etc/netplan/00-installer-config.yaml

    network:
      ethernets:
        eno1:
          dhcp4: true
          dhcp6: true
          optional: true
        enp6s0:
          dhcp4: true
          dhcp6: true
          optional: true
      version: 2
    
  • Wifi: /etc/netplan/50-cloud-init.yaml

    wifis:
      wlan0:
        dhcp4: true
        dhcp6: true
        optional: true
        access-points:
          "***":
            password: "***"
    
  • Swap Space

    sudo swapon -s
    sudo swapoff -a
    sudo fallocate -l 4G /swapfile
    sudo chmod 600 /swapfile
    sudo mkswap /swapfile
    sudo swapon /swapfile
    sudo swapon -s
    echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
    

VSCode

  • Tunnels

    curl -Lk 'https://code.visualstudio.com/sha/download?build=stable&os=cli-alpine-x64' --output vscode_cli.tar.gz
    tar -xf vscode_cli.tar.gz
    ./code tunnel service install
    sudo loginctl enable-linger $USER
    

Vim

  • Install

    sudo apt install vim
    
  • ~/.vimrc

    set number
    syntax on
    

Git

  • Install

    sudo add-apt-repository ppa:git-core/ppa
    sudo apt install git
    
  • ~/.gitconfig

    [user]
        email = [email protected]
    [alias]
        co = checkout
        s = status
        d = diff
    [core]
        editor = vim
    

ZSH

  • Install

    sudo apt install zsh
    sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
    
  • ~/.zshrc

    ZSH_THEME="steeef"
    
  • EC2

    sudo vi /etc/passwd
    username:x:1634231:100:Your Name:/home/username:/bin/zsh
    

NodeJS

  • Install

    sudo apt install build-essential
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
    nvm install --lts
    nvm use --lts
    

Java

  • MacOS

    brew tap homebrew/cask-versions
    brew install corretto8 --cask
    
    export M2_HOME=$HOME/maven
    export PATH=$M2_HOME/bin:$PATH
    export PATH=/opt/homebrew/bin:$PATH
    
  • Corretto 16 Install

Startup

  • sudo touch /etc/systemd/system/azores.service

    [Unit]
    Description=Azores
    After=network.service
    
    [Service]
    ExecStart=/home/[username]/azores.sh
    
    [Install]
    WantedBy=default.target
    
  • touch azores.sh

    #!/bin/sh
    
    CMD="java -jar /home/[username]/server.jar > /home/[username]/server.log"
    #sudo -u [username] screen -dmS [screenname] bash -c "$CMD"
    su - [username] -c screen -dmS [screenname] bash -c "$CMD"
    
    chmod +x azores.sh
    sudo systemctl start azores
    sudo systemctl enable azores
    

SSH

  • Server

    sudo ssh-keygen -A
    sudo apt install openssh-server
    sudo systemctl enable ssh
    # optional: copy over .ssh folder
    eval $(ssh-agent -s)
    ssh-add
    
  • Create key

    ssh-keygen -t ed25519 -C [email protected]
    eval $(ssh-agent -s)
    ssh-add ~/.ssh/id_ed25519
    

GPG

  • Import/Export

    gpg --list-keys
    gpg --export --armor <id>
    gpg -a --export-secret-key <id>
    
    gpg --import
    <paste>
    ctrl+d
    
  • Autosign

    gpg --list-secret-keys --keyid-format=long
    git config --global user.signingkey <id>
    git config --global commit.gpgsign true
    
    export GPG_TTY=$(tty)
    
  • TTL

    // sudo apt install gnupg-agent
    // eval $(gpg-agent --daemon)
    

    ~/.gnupg/gpg-agent.conf

    default-cache-ttl 86400
    max-cache-ttl 86400
    
  • Create key

    gpg --full-generate-key
    
  • MacOS

    brew install pinentry-mac
    echo "pinentry-program /opt/homebrew/bin/pinentry-mac" >> ~/.gnupg/gpg-agent.conf
    gpgconf --kill gpg-agent && gpg-agent --daemon
    

Python

  • Install

    sudo add-apt-repository ppa:deadsnakes/ppa
    sudo apt install python3.9 python3.9-dev python3.9-venv
    sudo apt install python3.10 python3.10-dev python3.10-venv
    sudo apt install python3.11 python3.11-dev python3.11-venv
    sudo apt install python3.12 python3.12-dev python3.12-venv
    
    • Fix apt_pkg error on sudo apt update:
    sudo apt-get install python3-apt --reinstall
    cd /usr/lib/python3/dist-packages
    sudo cp apt_pkg.cpython-38-x86_64-linux-gnu.so apt_pkg.so
    
  • Versions

    sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1
    sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 2
    sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 3
    sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 4
    sudo update-alternatives --config python3
    
  • Pip

    sudo apt install python3-pip
    

    or

    curl -OL https://bootstrap.pypa.io/get-pip.py
    python3 get-pip.py
    
    export PATH=$HOME/.local/bin:$PATH
    
  • Venv

    python3 -m venv venv
    

CUDA

  • Install

    Tensorflow compatibility

    wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-keyring_1.1-1_all.deb
    sudo dpkg -i cuda-keyring_1.1-1_all.deb
    sudo apt update
    sudo apt install cuda-drivers-555
    sudo apt-mark hold cuda-drivers-555
    
    sudo apt install cuda-toolkit-12-5
    
    sudo apt list -a cudnn
    sudo apt install cudnn=9.3.0-1
    sudo apt-mark hold cudnn
    
    export PATH=/usr/local/cuda-12.5/bin${PATH:+:${PATH}}
    export LD_LIBRARY_PATH=/usr/local/cuda-12.5/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
    

Over/underclock

  • Pi: /boot/firmware/config.txt

    [pi5]
    arm_freq=1000
    arm_freq_min=600
    gpu_freq=400
    over_voltage=-2
    arm_boost=0
    force_turbo=0
    
    lscpu
    

Syncthing

SDRPP

  • Install

    sudo launchctl stop com.sdrplay.sdrplay_service
    

Logging

  • Papertrail

    curl -OL [rsyslog].deb
    sudo dpkg -i [rsyslog].deb
    mkdir ~/logs
    touch ~/logs/[app].log
    sudo systemctl start remote_syslog
    sudo systemctl enable remote_syslog
    sudo vi /etc/log_files.yml
    
    files: 
      - /path/to/your/file.log
    destination:
      host: logs2.papertrailapp.com
      port: 123
      protocol: tls
    pid_file: /var/run/remote_syslog.pid
    

MySQL

  • Install

    sudo apt install mysql-server
    sudo systemctl status mysql
    sudo systemctl enable mysql
    sudo mysql_secure_installation
    
    brew install [email protected]
    echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
    source ~/.zshrc
    brew link --force [email protected]
    brew services start [email protected]
    sudo mysql_secure_installation
    
  • /etc/mysql/my.cnf

    [mysqld]
    character-set-server=utf8mb4
    collation-server=utf8mb4_general_ci
    default-time-zone='+00:00'
    wait_timeout=999999999
    interactive_timeout=999999999
    
    sudo mysql
    mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
    mysql> FLUSH PRIVILEGES;
    mysql> exit
    sudo systemctl restart mysql
    
  • Import/Export

    mysqldump -uroot -p reversi > reversi.sql
    mysql -uroot -p reversi < reversi.sql
    

Sound

  • Alsa setup

    sudo apt install alsa-utils alsa-oss
    sudo usermod --append --groups audio <username>
    sudo reboot
    

    List devices:

    aplay -l
    arecord -l
    

    Stream:

    ffmpeg -f alsa -i hw:3 -f alsa hw:2
    ffmpeg -f alsa -i hw:3 -af 'asetrate=48000*1.0091,aresample=48000,atempo=1/1.0091' -f alsa hw:2
    
  • IQAudio

    #dtparam=audio=on
    dtoverlay=iqaudio-dacplus
    dtoverlay=iqaudio-dacplus,auto_mute_amp
    

Airplay

  • Install shairport-sync

    README

    sudo apt install alsa-utils systemd-dev
    sudo usermod --append --groups audio <username>
    sudo apt install --no-install-recommends build-essential git autoconf automake libtool \
        libpopt-dev libconfig-dev libasound2-dev avahi-daemon libavahi-client-dev libssl-dev libsoxr-dev \
        libplist-dev libsodium-dev libavutil-dev libavcodec-dev libavformat-dev uuid-dev libgcrypt-dev xxd
    
    git clone https://github.com/mikebrady/nqptp.git
    cd nqptp
    autoreconf -fi
    ./configure --with-systemd-startup
    make
    sudo make install
    sudo systemctl enable nqptp
    sudo systemctl start nqptp
    
    git clone https://github.com/mikebrady/shairport-sync.git
    cd shairport-sync
    autoreconf -fi
    ./configure --sysconfdir=/etc --with-alsa \
        --with-soxr --with-avahi --with-ssl=openssl --with-systemd --with-airplay-2
    make
    sudo make install
    sudo systemctl enable shairport-sync
    
  • /etc/shairport-sync.conf

    general = {
        name = "Bedroom";
        resync_threshold_in_seconds = 0.150;
    };
    
    alsa = {
        output_device = "hw:1,0";
    };
    
    sudo systemctl start shairport-sync
    

OpenWRT

  • Download: https://downloads.openwrt.org/snapshots/targets/bcm27xx/bcm2711/

  • Image Builder

    sudo apt install build-essential libncurses5-dev libncursesw5-dev zlib1g-dev gawk git gettext libssl-dev xsltproc wget unzip python
    # kmod-r8169: RTL8111
    # kmod-usb-net-rtl8152: RTL8152
    make info
    make image PROFILE=rpi-4 PACKAGES="kmod-r8169 luci luci-ssl"
    
  • Install

    sudo fdisk -l
    gunzip openwrt-21.02.0-bcm27xx-bcm2711-rpi-4-ext4-factory.img.gz
    sudo dd if=openwrt-21.02.0-bcm27xx-bcm2711-rpi-4-ext4-factory.img of=/dev/sda bs=4K
    sudo parted /dev/sda
    (parted) print
    (parted) resizepart 2 30G
    (parted) print
    (parted) quit
    sudo resize2fs /dev/sda2
    
    ssh [email protected]
    passwd
    
  • Update

    opkg update
    opkg install screen
    screen -S update
    opkg update && opkg list-upgradable| awk '{print $1}'| tr '\n' ' '| xargs -r opkg upgrade
    

    CM4 wifi fix:

    cd /lib/firmware/brcm
    cp brcmfmac43455-sdio.raspberrypi,4-model-b.txt brcmfmac43455-sdio.raspberrypi,4-compute-module.txt
    reboot
    
  • /etc/config/network

    config globals 'globals'
        ...
        packet_steering '1'
    
    config interface 'wan'
            option ifname 'eth0.201' # centurylink
            option proto 'pppoe'
            option username '***'
            option password '***'
            option mtu '1492'
            option peerdns '0'
            option dns '1.1.1.1 1.0.0.1'
    
    config interface 'lan'
            option type 'bridge'
            option ifname 'eth1'
            option proto 'static'
            option ipaddr '11.0.0.1'
            option netmask '255.255.255.0'
            option ip6assign '60'
    
  • /etc/config/wireless

    config wifi-device 'radio0'
            option type 'mac80211'
            option channel '100'
            option hwmode '11a'
            option path 'platform/soc/fe300000.mmcnr/mmc_host/mmc1/mmc1:0001/mmc1:0001:1'
            option legacy_rates '0'
            option htmode 'VHT40'
            option disabled '0'
            option country 'US'
    
    config wifi-iface
            option device 'radio0'
            option network 'lan'
            option mode 'ap'
            option ssid '***'
            option encryption 'sae'
            option key '***'
    
    config wifi-device 'radio1'
            option type 'mac80211'
            option channel '1'
            option hwmode '11g'
            option path 'platform/soc/fe300000.mmcnr/mmc_host/mmc1/mmc1:0001/mmc1:0001:1'
            option legacy_rates '0'
            option htmode 'HT20'
            option short_gi_40 '0'
            option disabled '0'
            option country 'US'
    
    config wifi-iface
            option device 'radio1'
            option network 'lan'
            option mode 'ap'
            option ssid '***'
            option encryption 'sae'
            option key '***'
    
  • /etc/config/firewall

    config defaults
        option flow_offloading 1
        option flow_offloading_hw 1
    
    config redirect
        option name 'forward 8080'
        option src 'wan'
        option dest 'lan'
        option src_dport '8080'
        option dest_ip '11.0.0.200'
        option dest_port '8080'
        option target 'DNAT'
    

Raspberry Pi eMMC

  1. sudo ./rpiboot (usbboot)
  2. Toggle RPiBOOT switch
  3. Power on

Other

  • Disable bluetooth

    sudo systemctl disable bluetooth.service
    
  • Apple keyboard Fn default off

    sudo bash -c "echo 2 > /sys/module/hid_apple/parameters/fnmode"
    echo options hid_apple fnmode=2 | sudo tee -a /etc/modprobe.d/hid_apple.conf
    sudo update-initramfs -u -k all
    
  • Nvidia font fix

    sudo nvidia-xconfig --no-use-edid-dpi 
    # Add under "monitor": Option "DPI" "96 x 96"
    
  • Terminator layout custom command

    cd /home/username/Documents; exec zsh
    
  • Read-only filesystem fix

    sudo fsck.ext4 -f /dev/sda1
    
  • Github Pages on Cloudflare

    • DNS only root and www CNAME's
    • Wait for Github to retrieve TLS cert
    • Enforce https
    • Switch records to proxied
    • Change SSL/TLS encryption to Full (strict)
  • Util

    • ncdu
  • Windows ISO boot

    sudo sh Ventoy2Disk.sh -i /dev/sda
    sudo mount /dev/sda /media/usb1
    
  • RTL8125 Ethernet interface

    sudo add-apt-repository ppa:awesometic/ppa
    sudo apt install realtek-r8125-dkms
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment