dotfiles/setup/ubuntu-setup.md
DuckDuckWhale 9736e73c8e
Misc: setup, fish, auto, helix, starship, system
- Setup: add Fedora guides, Signal, Dynamic Desktop, and Flatseal
- Shells: fix $() on older fish versions and unalias batcat on Fedora
- Auto:
    - Detect git dependency
    - Add .clang-format for C/C++ family
    - Add full-setup script
- Helix: update to 24.03, add text width, rulers, and fix reflow
- Rust: fix fish env
- Starship: fix config path
- System: rename mac fnmode scripts and update sshd_config
2024-07-02 19:04:41 -07:00

11 KiB

Ubuntu Setup

Here's my personal Ubuntu 23.10 setup. (Make sure to use Wayland on Nvidia!)

Packages

  • Must haves:
    • sudo apt install alacritty curl deja-dup earlyoom endeavour ffmpeg fish flatpak git gnome-boxes gnome-clocks gnome-software-plugin-flatpak gnome-sound-recorder gnome-weather goldendict gparted keepassxc mpv needrestart obs-studio ripgrep sshfs synaptic tmux trash-cli ufw vim-gtk3 wl-clipboard linux-tools-generic build-essential
  • Optional:
    • sudo apt install arp-scan asciinema bookworm foliate gimp gnome-firmware gnome-games gnome-nettool gnome-packagekit gnome-passwordsafe gnome-shell-pomodoro gnome-usage gthumb heif-gdk-pixbuf heif-thumbnailer mkvtoolnix-gui openjdk-17-jdk pulseeffects qpdf ranger syncplay virtualbox-qt vlc audacity f3 prusa-slicer cmake gstreamer1.0-plugins-bad ddcutil shadowsocks-libev qemu-user-static podman
  • Remove all snaps:
    • # if this command fails, do the following then try again:
      # sudo umount /var/snap/firefox/common/host-hunspell
      sudo apt autoremove --purge snapd
      sudo apt-mark hold snapd
      trash ~/snap
      
  • Enable FlatHub:
    • flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
  • earlyoom config: edit /etc/default/earlyoom and add:
    • --avoid '(^|/)(systemd|sshd|mosh-server|ssh|vim|sudo|sudoedit|gnome-shell|gnome-terminal-)$' --prefer '(^|/)(Web Content|Isolated Web Co)$'

Optional packages

  • clangd for VSCodium C language server with llvm-vs-code-extensions.vscode-clangd (?)
  • imagemagick for convert, comment out with <!-- --> PDF policy in /etc/ImageMagick-6/policy.xml (?)
    • Or graphicsmagick-imagemagick-compat, which doesn't need this policy change somehow.
  • Cross compiling (?)
    • gcc-aarch64-linux-gnu
    • gcc-arm-linux-gnueabihf
  • Virtualbox
    • sudo usermod -aG vboxusers $(whoami)
  • Birdtray
  • ddcutil for monitor brightness shortcuts:
    • sudo usermod -aG i2c $(whoami)
    • External Monitor Brightness Up: ddcutil setvcp 10 + 10
    • External Monitor Brightness Down: ddcutil setvcp 10 - 10

Apps

  • gnome-tweaks
    • sudo apt install gnome-tweaks
  • Extensions
    • sudo apt install gnome-shell-extensions
  • Go to settings -> Region & Language and install Chinese (simplified).
  • GSConnect
    • sudo apt install gnome-shell-extension-gsconnect
    • UFW:
      • sudo ufw allow 1716:1764/tcp
      • sudo ufw allow 1716:1764/udp

Flatpaks

Use Flatseal to lock down all of them: flatpak install flathub com.github.tchx84.Flatseal

  • Firefox
    • flatpak install flathub org.mozilla.firefox
  • Xournal++
    • sudo apt install xournalpp texlive-latex-extra
  • cameractrls
    • flatpak install hu.irl.cameractrls
  • Minecraft
    • flatpak install flathub org.prismlauncher.PrismLauncher
    • To host servers: sudo ufw allow 25565/tcp
  • Bottles
    • flatpak install flathub com.usebottles.bottles
  • Signal
    • Use Wayland. Disable ...login1.
    • flatpak install flathub org.signal.Signal
  • Discord
    • flatpak install flathub com.discordapp.Discord
  • Slack
    • There are some suspicious permissions. I would lock them down with Flatseal and use Wayland.
    • flatpak install flathub com.slack.Slack
  • Denaro
    • flatpak install flathub org.nickvision.money
  • OBS
    • flatpak install flathub com.obsproject.Studio
    • Background removal plugin:
      • flatpak install com.obsproject.Studio.Plugin.BackgroundRemoval
  • Video Trimmer
    • flatpak install flathub org.gnome.gitlab.YaLTeR.VideoTrimmer
  • Pods
    • flatpak install com.github.marhkb.Pods
  • Dynamic Wallpaper Editor
    • flatpak install flathub com.github.maoschanz.DynamicWallpaperEditor
  • Dynamic Wallpaper
    • flatpak install flathub me.dusansimic.DynamicWallpaper

Optional Apps

  • Steam
    • flatpak install flathub com.valvesoftware.Steam
  • Zoom
    • flatpak install flathub us.zoom.Zoom
  • Impatience (adjust Gnome animation speed)
    • sudo apt install gnome-shell-extension-impatience
    • Enable in extensions and set speed to 0.7
  • Wobbly Windows (?)
  • System monitor
    • $ sudo apt install gnome-shell-extension-system-monitor
    • Show only CPU (digit and graph) and memory (digit).
  • OpenWeatherMap
    • $ sudo apt install gnome-shell-extension-weather
    • On older systems (< 21.04), download and install from https://extensions.gnome.org/extension/750/openweather/
    • Set location to La Jolla
    • Switch to metric units
  • VS Codium
    • flatpak install flathub com.vscodium.codium
  • Birdtray
  • Android Studio
    • Move Ctrl+S from IdeaVim to IDE
    • Enabled Mark modified (*)
    • Disable both Save files on frame deactivation and Save files automatically if application is idle

Services & System configs

Swap partition/file

  • Allocate 32 GiB for LVM swap partition (if not set during installation):
    sudo swapoff -a
    sudo lvcreate -n swap-ubuntu-23.10 -L 32G -C y <device>
    # note down UUID:
    sudo mkswap /dev/mapper/<device>-swap--ubuntu--23.10
    echo 'UUID=<UUID> none swap swap 0 0' | sudo tee -a /etc/fstab > /dev/null
    sudo swapon -a
    
  • Or, allocate n GiB for swapfile:
    # if /swapfile already exists
    sudo swapoff /swapfile
    sudo fallocate -l <n>GiB /swapfile
    sudo chmod 0600 /swapfile
    sudo mkswap /swapfile
    sudo swapon /swapfile
    echo '/swapfile none swap defaults 0 0' | sudo tee -a /etc/fstab > /dev/null
    

OpenSSH Server & Mosh & UFW

Installation and configuration:

sudo apt install -y openssh-server mosh
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
sudo cp ../system/sshd/sshd_config /etc/ssh/sshd_config
sudo groupadd --system ssh-users
sudo usermod -aG ssh-users $(whoami)
sudo systemctl enable ssh --now
sudo systemctl reload ssh

Firewall:

sudo ufw limit OpenSSH # sudo ufw limit 22/tcp
sudo ufw allow mosh # sudo ufw allow 60001:60999/udp # mosh profile includes unused 60000 & 61000
sudo ufw show added
# check before you enable
sudo ufw enable

Per user:

mkdir -p ~/.ssh
chmod 700 ~/.ssh
# insert your SSH public keys into this file
touch ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys

My system level dotfiles

See the system folder and run each script as they apply to your installation.

See logs as admin (if not yet in adm group)

sudo usermod -aG adm $(whoami)

Simplified Chinese Font Priority Fix

Move SC to the top by:

$ sudoedit $(realpath /etc/fonts/conf.d/64-language-selector-cjk-prefer.conf)

Source: https://askubuntu.com/questions/901486/%E9%97%A8-looks-weird-on-my-system-default-font

Legacy

For old Ubuntu versions

  • OBS Studio
    • On Ubuntu <= 22.10, fixed in 23.04:
      • $ sudo apt install qtwayland5
    • On Ubuntu < 22.10, in /usr/share/applications/com.obsproject.Studio.desktop, replace Exec=obs with Exec=sh -c '[ "$XDG_SESSION_TYPE" = "wayland" ] && obs -platform wayland || obs'
  • Xournal++
    • < Ubuntu 22.04
      • flatpak install flathub com.github.xournalpp.xournalpp
      • flatpak install flathub org.freedesktop.Sdk.Extension.texlive and choose newest (21.08 at time of writing) for LaTeX support.
  • OpenSSH server config deprecated alias for KbdInteractiveAuthentication
    • ChallengeResponseAuthentication
  • Mosh: trusted PPA from mosh developer for truecolor support
    • < Ubuntu 23.04
      • sudo add-apt-repository ppa:keithw/mosh-dev
  • Firefox
    • < 23.04
      • Forcing Wayland in Flatpak Firefox may consume more CPU in certain cases with gnome-shell taking close to 100% CPU
  • Digimend for Huion tablet (works with H640p)
    • >= 21.10 & using Wayland: no longer necessary
    • = 21.04:
      • $ sudo apt install digimend-dkms
      • Reboot.
    • < 21.04:
      • Download and install from https://github.com/DIGImend/digimend-kernel-drivers.
  • Nvidia proprietary driver screen tearing fix
    • Ubuntu < 22.04
      • `echo 'options nvidia-drm modeset=1' | sudo tee /etc/modprobe.d/nvidia-drm-nomodeset.conf

        /dev/null`

Dual booting with Windows

Dislocker

$ sudo apt install dislocker
$ sudo mkdir /media/"$(whoami)" /mnt/dislocker /opt/dislocker
$ sudo chmod 700 /media/"$(whoami)" /mnt/dislocker /opt/dislocker
$ sudo chown $user:$user /media/"$(whoami)"
$ sudo chown root:root /mnt/dislocker /opt/dislocker

Copy the .BEK file to /opt/dislocker/"$(whoami)".bek.

$ sudo chown root:root /opt/dislocker/"$(whoami)".bek
$ sudo chmod 700 /opt/dislocker/"$(whoami)".bek

Add the following lines to /etc/fstab with <user> replaced:

/dev/nvme0n1p6 /mnt/dislocker fuse.dislocker nofail,nouser,umask=0077,bekfile=/opt/dislocker/<user>.bek 0 0
/mnt/dislocker/dislocker-file /media/<user> auto nofail,umask=0077,gid=<user>,uid=<user> 0 0

Mount manually with:

$ sudo dislocker /dev/nvmen1p6 -p -- /mnt/dislocker
$ sudo mount -o loop /mnt/dislocker/dislocker-file /media/"$(whoami)"

Unused

Razer mouse

sudo add-apt-repository ppa:polychromatic/stable
sudo apt install openrazer-meta polychromatic

Grub background

Tool:

  • $ sudo apt install grub-customizer
  • Put in background manually

Manual Script:

sudo mkdir /opt/grub
sudo cp -r background/ /boot/grub/
sudo chown -R root:root /opt/grub
sudo chmod -R 700 /opt/grub
  • Add the following lines to /opt/grub/cycle-backgrounds.sh:
    #!/bin/sh
    cd /boot/grub/background
    mv background.png tmp.png
    mv background-1.png background.png
    mv tmp.png background-1.png
    
  • $ sudo chown root:root /opt/grub/cycle-backgrounds.sh
  • $ sudo chmod 700 /opt/grub/cycle-backgrounds.sh
  • Add @reboot /opt/grub/cycle-backgrounds.sh to root crontab.
  • In /etc/default/grub:
    • Add GRUB_BACKGROUND=/boot/grub/background/background.png
    • Change GRUB_TIMEOUT=10 to GRUB_TIMEOUT=3
  • $ sudo update-grub

Proton black screen fix

Source: https://github.com/ValveSoftware/steam-runtime/issues/312#issuecomment-739441559

sudo mv /usr/share/vulkan/icd.d/intel_icd.x86_64.json \
	/usr/share/vulkan/icd.d/intel_icd.x86_64.json.disabled

Proprietary encodings

  • $ sudo apt install ubuntu-restricted-extras

Blank screen workaround

Blanked screen doesn't wake up after locking [drmModeAtomicCommit: Argument invalide] [drmModeAtomicCommit: Invalid argument] - Put MUTTER_DEBUG_ENABLE_ATOMIC_KMS=0 in /etc/environment