Skip to content

Instantly share code, notes, and snippets.

@HackingGate
Last active May 31, 2025 09:03
Show Gist options
  • Save HackingGate/3dbcf2264ccf7dbb7465560ca1cf9edc to your computer and use it in GitHub Desktop.
Save HackingGate/3dbcf2264ccf7dbb7465560ca1cf9edc to your computer and use it in GitHub Desktop.
My Ubuntu Desktop Setup
#!/bin/bash
set -e
set -o pipefail
# Install 1Password password manager
sudo apt update && sudo apt install 1password -y
# Install vanilla GNOME desktop environment (without Ubuntu modifications)
sudo apt purge pipewire-alsa pipewire-audio -y
sudo apt install vanilla-gnome-desktop vanilla-gnome-default-settings -y
# Install Refine from Flatpak for advanced GNOME customization
sudo flatpak install page.tesk.Refine -y
# Install GNOME Tweaks for additional system settings
sudo apt install gnome-tweaks -y
# Install Ghostty terminal emulator from Snap
sudo snap install ghostty --classic
# Configure terminal environment for Ghostty
echo '
# Set TERM variable for Ghostty terminal emulator
if [[ "${TERM-}" == "xterm-ghostty" ]]; then
export TERM="xterm-256color"
fi' >> ~/.zshrc
# Set Ghostty as the default terminal emulator
sudo update-alternatives --install /usr/bin/x-terminal-emulator x-terminal-emulator /snap/bin/ghostty 100
# Configure default terminal when prompted
sudo update-alternatives --config x-terminal-emulator
# Add common applications to the GNOME dock
gsettings set org.gnome.shell favorite-apps "['org.gnome.Nautilus.desktop', 'org.gnome.Software.desktop', 'org.mozilla.firefox.desktop', 'com.brave.Browser.desktop', '1password.desktop', 'code.desktop', 'ghostty_ghostty.desktop']"
# List all installed GNOME Shell extensions
gnome-extensions
# Disable Ubuntu-specific GNOME extensions
gnome-extensions disable [email protected]
gnome-extensions disable [email protected]
gnome-extensions disable [email protected]
# Install pipx for isolated Python application installation
sudo apt update
sudo apt install pipx
pipx ensurepath
source ~/.zshrc
# Install GNOME Extensions CLI tool
pipx install gnome-extensions-cli --system-site-packages
# Install useful GNOME Shell extensions
gext install [email protected]
gext install [email protected]
gext install [email protected]
gext install customreboot@nova1545
# Disable GNOME Shell hot corners feature
gsettings set org.gnome.desktop.interface enable-hot-corners false
# Disable tap-to-click for touchpad
gsettings set org.gnome.desktop.peripherals.touchpad tap-to-click false
# Change Ubuntu theme from default to blue variant
gsettings set org.gnome.desktop.interface gtk-theme 'Yaru-blue-dark'
gsettings set org.gnome.desktop.interface icon-theme 'Yaru-blue-dark'
# Install fcitx5 input method framework for better CJK input support
# fcitx5-table-extra provides 倉頡、鄭碼、行列、輕鬆、嘸蝦米輸入法、速成、五筆、筆順五碼、粵語拼音、廣東拼音、港式廣東話、吳語注音
# Reference: https://chakra-zh.blogspot.com/2015/10/fcitx-chinese-input-on-chakra-linux.html
sudo apt install fcitx5 fcitx5-chewing fcitx5-mozc fcitx5-table-extra -y
# Configure fcitx5 as the default input method
im-config -n fcitx5
# Configure fcitx5 to start automatically
mkdir -p ~/.config/autostart && cp /usr/share/applications/org.fcitx.Fcitx5.desktop ~/.config/autostart
# Install KDE Input Method Panel extension
gext install [email protected]
# Install GJS On-Screen Keyboard
gext install [email protected]
# Install Visual Studio Code
sudo apt-get install wget gpg
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg
echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" |sudo tee /etc/apt/sources.list.d/vscode.list > /dev/null
rm -f packages.microsoft.gpg
sudo apt install apt-transport-https
sudo apt update
sudo apt install code # or code-insiders
# Install JetBrains Toolbox
sudo add-apt-repository universe -y
sudo apt install -y libfuse2t64 jq
# Create target directory if it doesn't exist
mkdir -p "${HOME}/.local/bin"
# Ensure .local/bin is in PATH
if [[ ":$PATH:" != *":$HOME/.local/bin:"* ]]; then
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc
export PATH="$HOME/.local/bin:$PATH"
echo "Added ~/.local/bin to PATH"
fi
# Store download URL in a variable
TOOLBOX_URL=$(curl -s 'https://data.services.jetbrains.com/products/releases?code=TBA&latest=true&type=release' | jq -r '.TBA[0].downloads.linux.link')
# Download with progress bar and extract with quoted wildcard pattern
curl -L# "$TOOLBOX_URL" | tar xzvf - -C "${HOME}/.local/bin" --strip-components=1 --wildcards '*/jetbrains-toolbox'
# Make the binary executable
chmod +x "${HOME}/.local/bin/jetbrains-toolbox"
echo "JetBrains Toolbox installed to ${HOME}/.local/bin/jetbrains-toolbox"
#!/bin/bash
set -e
set -o pipefail
# Set system timezone to Tokyo, Japan
sudo timedatectl set-timezone Asia/Tokyo
# Configure hardware clock to use UTC (recommended for Linux)
sudo timedatectl set-local-rtc 0
# Display current time and date settings
timedatectl
# Reference to guide for making Windows 11 use UTC for hardware clock (for dual-boot systems)
# https://gist.github.com/HackingGate/180aafbc6342ad4b1cb31309fa83c91a
# Install essential development tools and utilities
sudo apt update
sudo apt upgrade -y
sudo apt install emacs-nox vim neovim curl wget gh git build-essential zsh efibootmgr jq neofetch htop -y
# Setup git global configuration
git config --global user.name "HackingGate"
git config --global user.email "[email protected]"
git config --global core.editor "emacs"
git config --global init.defaultBranch main
git config --global gpg.format ssh
git config --global commit.gpgSign true
git config --global submodule.recurse true
# Install Oh My Zsh for better terminal experience
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# Install Homebrew package manager for Linux
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo >> ~/.zshrc
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> ~/.zshrc
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
brew install gcc
# Configure Flatpak for application management
sudo apt install flatpak gnome-software-plugin-flatpak -y
sudo flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
sudo flatpak update
# Install GNOME Extensions utility
sudo flatpak install flathub org.gnome.Extensions -y
# Install GNOME Extension Manager for easier extension management
sudo flatpak install flathub com.mattjakeman.ExtensionManager -y
# Install GSConnect for integration with Android devices
sudo dnf install gnome-shell-extension-gsconnect -y
# Replace snap Firefox with Flatpak version
sudo snap remove firefox
sudo flatpak install flathub org.mozilla.firefox
# Install Brave browser
sudo apt install curl -y
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
sudo apt install brave-browser -y
# Debloat Brave browser by disabling certain features
sudo mkdir -p /etc/brave/policies/managed/ && sudo chmod 755 /etc/brave/policies/managed/
sudo tee /etc/brave/policies/managed/00_debloat.json > /dev/null << 'EOF'
{
"TorDisabled": true,
"BraveRewardsDisabled": true,
"BraveWalletDisabled": true,
"BraveVPNDisabled": true,
"BraveAIChatEnabled": false
}
EOF
# Install Thunderbird email client
sudo flatpak install flathub org.mozilla.Thunderbird
# Set Firefox as the default web browser
xdg-settings set default-web-browser org.mozilla.firefox.desktop
# Update snap packages
sudo snap refresh
# Configure Emacs as the default text editor
sudo update-alternatives --set editor /usr/bin/emacs
echo '
# Set default editor to Emacs
export EDITOR="/usr/bin/emacs"
export VISUAL="/usr/bin/emacs"
' >> ~/.zshrc
# Install 1Password password manager and CLI
# https://support.1password.com/install-linux/#debian-or-ubuntu
curl -sS https://downloads.1password.com/linux/keys/1password.asc | sudo gpg --dearmor --output /usr/share/keyrings/1password-archive-keyring.gpg
echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/1password-archive-keyring.gpg] https://downloads.1password.com/linux/debian/amd64 stable main' | sudo tee /etc/apt/sources.list.d/1password.list
sudo mkdir -p /etc/debsig/policies/AC2D62742012EA22/
curl -sS https://downloads.1password.com/linux/debian/debsig/1password.pol | sudo tee /etc/debsig/policies/AC2D62742012EA22/1password.pol
sudo mkdir -p /usr/share/debsig/keyrings/AC2D62742012EA22
curl -sS https://downloads.1password.com/linux/keys/1password.asc | sudo gpg --dearmor --output /usr/share/debsig/keyrings/AC2D62742012EA22/debsig.gpg
sudo apt update && sudo apt install 1password-cli 1password -y
op --version
# Setup SSH key from 1Password
mkdir -p ~/.ssh
# Sign in to 1Password CLI
eval $(op signin)
# Retrieve and install SSH key with specific fingerprint
echo "Retrieving SSH key with fingerprint SHA256:dsPhhaQhifJccmUhI2ZZIoSnEOUIWYRbSe1TWZs2JuA"
op item list --tags ssh-key --format json | jq -r '.[] | select(.title | contains("SHA256:dsPhhaQhifJccmUhI2ZZIoSnEOUIWYRbSe1TWZs2JuA")) | .id' | xargs -I {} op item get {} --format json | jq -r '.fields[] | select(.label | test("private|key", "i")) | .value' > ~/.ssh/id_ed25519
# Set proper security permissions
chmod 600 ~/.ssh/id_ed25519
echo "SSH key saved to ~/.ssh/id_ed25519"
# Setup 1Password browser integration for Flatpak
# https://gist.github.com/LinuxSBC/7c39374130d2d443871ddde64cba18a3 1password-flatpak-browser-integration.sh
curl -L https://gist.githubusercontent.com/LinuxSBC/7c39374130d2d443871ddde64cba18a3/raw/1password-flatpak-browser-integration.sh -o 1password-flatpak-browser-integration.sh
chmod +x 1password-flatpak-browser-integration.sh
./1password-flatpak-browser-integration.sh
# Auto start 1Password for GNOME Shell
mkdir -p ~/.config/autostart
cat > ~/.config/autostart/1password.desktop << 'EOF'
[Desktop Entry]
Name=1Password
Exec=/usr/bin/1password --silent %U
Terminal=false
Type=Application
Icon=1password
StartupWMClass=1Password
Comment=Password manager and secure wallet
MimeType=x-scheme-handler/onepassword;
Categories=Office;
EOF
chmod +x ~/.config/autostart/1password.desktop
echo "1Password autostart configured"
# Install Tailscale for secure networking
curl -fsSL https://tailscale.com/install.sh | sh
sudo tailscale up
# Install and configure Starship prompt
brew install starship
echo 'eval "$(starship init zsh)"' >> ~/.zshrc
# Install essential fonts including CJK support
sudo apt install -y fonts-firacode fonts-noto fonts-noto-cjk-extra fonts-noto-extra fonts-noto-ui-core fonts-noto-ui-extra fonts-noto-unhinted
# Install mainline for kernel management
sudo add-apt-repository ppa:cappelikan/ppa
sudo apt update
sudo apt install -y mainline gcc g++
# Automatically install latest stable longterm kernel
echo "Fetching latest longterm kernel information from kernel.org..."
KERNEL_JSON=$(curl -s https://www.kernel.org/releases.json)
LATEST_LONGTERM=$(echo "$KERNEL_JSON" | jq -r '.releases[] | select(.moniker=="longterm" and .iseol==false) | .version' | sort -V | tail -n 1)
if [ -n "$LATEST_LONGTERM" ]; then
echo "Found latest longterm kernel: $LATEST_LONGTERM"
# Extract major and minor versions (e.g., "6.12" from "6.12.28")
KERNEL_MAJOR_MINOR=$(echo "$LATEST_LONGTERM" | grep -o "^[0-9]\+\.[0-9]\+")
echo "Looking for kernel $KERNEL_MAJOR_MINOR.x in mainline..."
# Find the closest matching version in mainline
MAINLINE_VERSION=$(mainline list | grep "$KERNEL_MAJOR_MINOR" | sort -V | tail -n 1 | awk '{print $1}')
if [ -n "$MAINLINE_VERSION" ]; then
echo "Found matching kernel: $MAINLINE_VERSION"
# Check if this kernel is already installed
INSTALLED_KERNELS=$(mainline list-installed)
if echo "$INSTALLED_KERNELS" | grep -q "$MAINLINE_VERSION"; then
echo "Kernel $MAINLINE_VERSION is already installed. Skipping installation."
else
echo "Installing longterm kernel $MAINLINE_VERSION via mainline"
sudo mainline install "$MAINLINE_VERSION"
fi
else
echo "No matching version found in mainline for $KERNEL_MAJOR_MINOR.x"
fi
else
echo "Could not determine latest longterm kernel version"
fi
# Update and rebuild drivers for new kernel
echo "Checking and updating drivers for the new kernel..."
# Update package lists and upgrade packages
sudo apt update && sudo apt upgrade -y
# Rebuild DKMS modules for new kernel if needed
sudo dkms autoinstall
# Update GPU driver if it's NVIDIA
if command -v nvidia-smi &> /dev/null; then
echo "Updating NVIDIA drivers..."
# Reinstall the recommended NVIDIA driver
RECOMMENDED_DRIVER=$(ubuntu-drivers devices | grep "recommended" | awk '{print $3}' | head -n 1)
if [ -n "$RECOMMENDED_DRIVER" ]; then
echo "Installing recommended NVIDIA driver: $RECOMMENDED_DRIVER"
sudo apt reinstall "$RECOMMENDED_DRIVER" -y
# Remove old NVIDIA packages
dpkg -l \
| awk '/^rc/ && /nvidia/ { print $2 }' \
| xargs sudo apt purge -y
else
echo "Could not find recommended NVIDIA driver"
fi
fi
# Check and update system with ubuntu-drivers
if command -v ubuntu-drivers &> /dev/null; then
echo "Installing recommended drivers..."
sudo ubuntu-drivers install
else
echo "Installing ubuntu-drivers-common..."
sudo apt install ubuntu-drivers-common -y
sudo ubuntu-drivers install
fi
# Update firmware
sudo fwupdmgr refresh
sudo fwupdmgr update
echo "Driver updates completed for kernel $(uname -r)"
# Reboot to apply changes
# Install rEFInd boot manager
sudo apt install refind -y
# Configure rEFInd boot timeout
echo "Configuring rEFInd timeout to 5 seconds..."
if [ -f /boot/efi/EFI/refind/refind.conf ]; then
# Get current timeout value for feedback
CURRENT_TIMEOUT=$(grep -oP 'timeout \K[0-9]+' /boot/efi/EFI/refind/refind.conf)
# Replace any timeout value with 5
sudo sed -i 's/timeout [0-9]\+/timeout 5/' /boot/efi/EFI/refind/refind.conf
if [ -n "$CURRENT_TIMEOUT" ]; then
echo "rEFInd timeout successfully changed from $CURRENT_TIMEOUT to 5 seconds"
else
echo "rEFInd timeout successfully set to 5 seconds"
fi
else
echo "Warning: rEFInd configuration file not found at /boot/efi/EFI/refind/refind.conf"
fi
# Configure GRUB boot timeout
echo "Configuring GRUB timeout to 5 seconds..."
if [ -f /etc/default/grub ]; then
# Update GRUB_TIMEOUT parameter to 5
sudo sed -i 's/GRUB_TIMEOUT=[0-9]*/GRUB_TIMEOUT=5/' /etc/default/grub
# Apply changes
sudo update-grub
echo "GRUB timeout successfully set to 5 seconds"
else
echo "Warning: GRUB configuration file not found at /etc/default/grub"
fi
# Enable Emacs keybindings across GTK applications
gsettings set org.gnome.desktop.interface gtk-key-theme "Emacs"
# Enable Emacs daemon for better performance for current user (no sudo required)
systemctl --user enable --now emacs
# Install Spacemacs for Emacs
git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d
# Configure Caps Lock as Ctrl key
echo "Setting Caps Lock to function as Ctrl..."
current_options=$(gsettings get org.gnome.desktop.input-sources xkb-options)
if [[ $current_options == "@as []" ]]; then
# No existing options
gsettings set org.gnome.desktop.input-sources xkb-options "['ctrl:nocaps']"
else
# Append to existing options, removing surrounding brackets first
current_options=${current_options:5:-1}
gsettings set org.gnome.desktop.input-sources xkb-options "[$current_options, 'ctrl:nocaps']"
fi
@HackingGate
Copy link
Author

HackingGate commented Mar 26, 2022

Wake-on-LAN (WoL)

UEFI BIOS

ASUS: https://www.asus.com/global/support/FAQ/1045950/

Ubuntu

https://help.ubuntu.com/community/WakeOnLan

Command:

sudo apt update
sudo apt install ethtool
sudo ethtool enp6s0

Output:

Settings for enp6s0:
	Supported ports: [ TP MII ]
	Supported link modes:   10baseT/Half 10baseT/Full 
	                        100baseT/Half 100baseT/Full 
	                        1000baseT/Full 
	                        2500baseT/Full 
	Supported pause frame use: Symmetric Receive-only
	Supports auto-negotiation: Yes
	Supported FEC modes: Not reported
	Advertised link modes:  10baseT/Half 10baseT/Full 
	                        100baseT/Half 100baseT/Full 
	                        1000baseT/Full 
	                        2500baseT/Full 
	Advertised pause frame use: Symmetric Receive-only
	Advertised auto-negotiation: Yes
	Advertised FEC modes: Not reported
	Link partner advertised link modes:  10baseT/Half 10baseT/Full 
	                                     100baseT/Half 100baseT/Full 
	                                     1000baseT/Half 1000baseT/Full 
	Link partner advertised pause frame use: Symmetric
	Link partner advertised auto-negotiation: Yes
	Link partner advertised FEC modes: Not reported
	Speed: 1000Mb/s
	Duplex: Full
	Port: Twisted Pair
	PHYAD: 0
	Transceiver: internal
	Auto-negotiation: on
	MDI-X: Unknown
	Supports Wake-on: pumbg
	Wake-on: d
	Link detected: yes

Enable WoL

sudo ethtool -s enp6s0 wol g

Check if settings applied

sudo ethtool enp6s0

Output:

Settings for enp6s0:
...
	Wake-on: g
...

Persist across reboots

sudo apt install ifupdown

Add the following to the bottom of /etc/network/interfaces

auto enp6s0
iface enp6s0 inet dhcp
        up ethtool -s enp6s0 wol g

Raspberry Pi (always on)

Get Mac address

ip neighbor show [IP_ADDRESS_OF_TARGET_PC]

Install wakeonlan

sudo apt install wakeonlan

Shutdown target PC. Try this command to boot it.

wakeonlan [MAC_ADDRESS_OF_TARGET_PC]

@HackingGate
Copy link
Author

HackingGate commented Apr 9, 2022

Mount SMB (samba)

Setup

sudo mkdir /mnt/Shared /mnt/Unlimited/
sudo apt install cifs-utils

Mount

sudo mount -t cifs -o username=hg //192.168.4.1/Shared /mnt/Shared/
sudo mount -t cifs -o username=hg //192.168.4.1/Unlimited /mnt/Unlimited/

Automount (add to /etc/fstab)

//192.168.4.1/Shared /mnt/Shared cifs username=hg 0 0
//192.168.4.1/Unlimited /mnt/Unlimited cifs username=hg 0 0

Auto Reconnection with autofs

sudo apt-get install autofs
sudo mount -a

@HackingGate
Copy link
Author

Reboot into Windows only for one time

Edit the /etc/default/grub and replace GRUB_DEFAULT=0 with GRUB_DEFAULT=saved

sudo update-grub
WINDOWS_TITLE=`grep -i "^menuentry 'Windows" /boot/grub/grub.cfg|head -n 1|cut -d"'" -f2`
echo "Rebooting into "$WINDOWS_TITLE""
sudo grub-reboot "$WINDOWS_TITLE"
sudo reboot

From: https://unix.stackexchange.com/a/112284/267632

@HackingGate
Copy link
Author

HackingGate commented Aug 27, 2022

ohmyzsh

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

starship

FiraCode Nerd Font

mkdir ~/Downloads/FiraCode
cd ~/Downloads/FiraCode
wget https://github.com/ryanoasis/nerd-fonts/releases/download/v2.1.0/FiraCode.zip
unzip FiraCode.zip
mkdir ~/.local/share/fonts
cp *.otf ~/.local/share/fonts
cd ..
rm -rf FiraCode

Install through snapcraft

sudo snap install starship

Setup your shell to use Starship

echo '
eval "$(starship init zsh)"
' >> ~/.zshrc

@HackingGate
Copy link
Author

HackingGate commented Feb 24, 2025

Wake on LAN on netplan (new on Ubuntu 24.04)
/etc/netplan/01-network-manager-all.yaml

network:
  version: 2
  renderer: NetworkManager
  ethernets:
    enp7s0:
      match:
        macaddress: [MAC_ADDRESS]
      wakeonlan: true
      dhcp4: true

Apply

sudo netplan generate && sudo netplan apply

Problem?

Use ip a to check if your LAN is enp7s0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment