Skip to content

Instantly share code, notes, and snippets.

@jordanluyke
Last active July 19, 2026 18:49
Show Gist options
  • Select an option

  • Save jordanluyke/0118cb3d83c7b1f6659f1b4c470920d7 to your computer and use it in GitHub Desktop.

Select an option

Save jordanluyke/0118cb3d83c7b1f6659f1b4c470920d7 to your computer and use it in GitHub Desktop.
Ubuntu Setup

Ubuntu Setup

Server

Download

Imaging

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

Config ~/.vimrc

set number
syntax on

Git

Install

sudo add-apt-repository ppa:git-core/ppa
sudo apt install git

Config ~/.gitconfig

[user]
    email = x@y.z
[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)"

Config ~/.zshrc

ZSH_THEME="steeef"

EC2

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

Tmux

Install TPM + Plugins

git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm

Config ~/.tmux.conf

# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-resurrect'     # Save/restore sessions
set -g @plugin 'tmux-plugins/tmux-continuum'    # Auto save/restore

# Continuum settings
set -g @continuum-restore 'on'          # Auto restore on tmux start
set -g @continuum-save-interval '15'    # Save every 15 minutes

# Optional better defaults
set -g mouse on
set -g base-index 1
setw -g pane-base-index 1

# Initialize TPM (must be at the very bottom)
run '~/.tmux/plugins/tpm/tpm'

Install plugins: Ctrl+b I

tmux Quick Reference

Sessions

Command Shortcut / Command
New session tmux new -s name
New session (named) Ctrl+b :new -s name
List sessions tmux ls or Ctrl+b s
Attach to session tmux attach -t name
Detach from session Ctrl+b d
Switch to next session Ctrl+b )
Switch to previous session Ctrl+b (
Kill session tmux kill-session -t name

Windows (Tabs)

Command Shortcut
New window Ctrl+b c
Next window Ctrl+b n
Previous window Ctrl+b p
Switch to window Ctrl+b 0-9
Rename window Ctrl+b ,
Close window Ctrl+b &

Panes (Splits)

Command Shortcut
Split vertical (left/right) Ctrl+b %
Split horizontal (top/bottom) Ctrl+b "
Switch panes Ctrl+b + arrow keys
Cycle panes Ctrl+b o
Close pane Ctrl+b x
Zoom pane (fullscreen) Ctrl+b z (toggle)
Show pane numbers Ctrl+b q

Resurrect + Continuum

Command Shortcut
Manual Save Ctrl+b Ctrl+s
Manual Restore Ctrl+b Ctrl+r
Auto restore on start (enabled via continuum)

Useful Misc

Command Shortcut / Command
Scroll / Copy mode Ctrl+b [q to exit
Reload config Ctrl+b :source ~/.tmux.conf
Kill all tmux tmux kill-server
Mouse support set -g mouse on (in config)

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


Startup Service

Create service file:

sudo touch /etc/systemd/system/azores.service
[Unit]
Description=Azores
After=network.service

[Service]
ExecStart=/home/[username]/azores.sh

[Install]
WantedBy=default.target

Create script:

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 x@y.z
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 key
# 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

~/.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

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

CUDA Toolkit

sudo apt install cuda-toolkit-12-5

cuDNN

sudo apt list -a cudnn
sudo apt install cudnn=9.3.0-1
sudo apt-mark hold cudnn

Environment Setup

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 (Raspberry 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

Install

sudo mkdir -p /etc/apt/keyrings
sudo curl -L -o /etc/apt/keyrings/syncthing-archive-keyring.gpg https://syncthing.net/release-key.gpg
sudo apt update
sudo apt install syncthing
syncthing   # creates config file

Config

Edit ~/.local/state/syncthing/config.xml or ~/.config/syncthing/config.xml:

<gui>
    <address>0.0.0.0:8384</address>
</gui>
sudo systemctl enable syncthing@myuser.service
sudo systemctl start syncthing@myuser.service

SDRPP

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

macOS:

brew install mysql@5.7
echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
brew link --force mysql@5.7
brew services start mysql@5.7
sudo mysql_secure_installation

Config (/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

/boot/firmware/config.txt

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

AirPlay (shairport-sync)

Install

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

Config (/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

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 root@192.168.1.1
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

Network (/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'

Wireless (/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 '***'

Firewall (/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 CNAMEs
  • Wait for GitHub to retrieve TLS cert
  • Enforce HTTPS
  • Switch records to proxied
  • Change SSL/TLS encryption to Full (strict)

Utils

  • 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