Skip to content

Instantly share code, notes, and snippets.

@armstrongl
Last active May 3, 2025 02:01
Show Gist options
  • Select an option

  • Save armstrongl/f0d35c58dd14a19338d79fd92c2c10b2 to your computer and use it in GitHub Desktop.

Select an option

Save armstrongl/f0d35c58dd14a19338d79fd92c2c10b2 to your computer and use it in GitHub Desktop.
Set up Ubuntu 22.04 for development

Ubuntu 22.04 LTS Setup

Install the essentials

Install these before continuing.

sudo apt install -y curl xclip build-essential curl htop xclip unzip ubuntu-restricted-extras unrar zip p7zip-full rar whois traceroute font-manager sshfs net-tools tree screen expect ca-certificates gnupg lsb-release software-properties-common make smartmontools cmake

Git

sudo apt install -y git git-extras

ssh-keygen -t ed25519 -C "<email>"
eval "$(ssh-agent -s)" 
ssh-add ~/.ssh/id_ed25519
cat ~/.ssh/id_ed25519.pub
xclip -sel clip < ~/.ssh/id_rsa.pub
ssh -T [email protected]

git config --global user.name "<name>"
git config --global user.email "<email>"

Brew

See Homebrew on Linux.

mkdir homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew

eval "$(homebrew/bin/brew shellenv)"
brew update --force --quiet
chmod -R go-w "$(brew --prefix)/share/zsh"

Flatpak

sudo apt install -y flatpak
# sudo add-apt-repository ppa:alexlarsson/flatpak
# sudo apt update
# sudo apt install flatpak
sudo apt install -y gnome-software-plugin-flatpak
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak install flathub -y

Also see the following resources:

Docker

See Install Docker Engine on Ubuntu, Run the Docker daemon as a non-root user (Rootless mode), then Install the Compose standalone.

# Uninstall old versions
sudo apt-get remove docker docker-engine docker.io containerd runc

sudo apt-get update

# Install latest from repo
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null


sudo apt-get update

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin

# Post installation steps
sudo groupadd docker
sudo usermod -aG docker $USER
# Log out, then back in
newgrp docker

# Start Docker on boot
sudo systemctl enable docker.service
sudo systemctl enable containerd.service

If the above doesn’t work, use this:

sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu `lsb_release -cs` test"
sudo apt update
sudo apt install docker-ce

Rootless Docker

See Run the Docker daemon as a non-root user (Rootless mode) for tips, troubleshooting, and best practices.

# Disable system-wide Docker if ir's already running
sudo systemctl disable --now docker.service docker.socket

# If you installed Docker 20.10 or later with RPM/DEB packages, you should have dockerd-rootless-setuptool.sh in /usr/bin.
dockerd-rootless-setuptool.sh install
export PATH=/usr/bin:$PATH

# If the script isn't there, you can install in manually:
sudo apt-get install -y docker-ce-rootless-extras

Compose standalone

sudo curl -SL https://github.com/docker/compose/releases/download/v2.14.2/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose

Rust

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/bin
rustc --version

Python

See the official documentation if you run into issues or want to configure anything special.

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install -y python3

sudo apt-get install -y python3-pip python3-distutils-extra python3-wheel python3-gi python3-gi-cairo gir1.2-gtk-3.0 gir1.2-poppler-0.18 python3-setuptools

python3 --version

Golang

# Remove any previous installations
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.19.4.linux-amd64.tar.gz

# https://gist.github.com/codenoid/4806365032bb4ed62f381d8a76ddb8e6
printf "Checking latest Go version...\n";
LATEST_GO_VERSION="$(curl --silent https://go.dev/VERSION?m=text)";
LATEST_GO_DOWNLOAD_URL="https://golang.org/dl/${LATEST_GO_VERSION}.linux-amd64.tar.gz "

printf "cd to home ($USER) directory \n"
cd "/home/$USER"

printf "Downloading ${LATEST_GO_DOWNLOAD_URL}\n\n";
curl -OJ -L --progress-bar https://golang.org/dl/${LATEST_GO_VERSION}.linux-amd64.tar.gz

printf "Extracting file...\n"
tar -xf ${LATEST_GO_VERSION}.linux-amd64.tar.gz

export GOROOT="/home/$USER/go"
export GOPATH="/home/$USER/go/packages"
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

printf '⚠️  ADD (OR REPLACE) THIS LINE BELOW TO YOUR ~/.bashrc  ⚠️
export GOROOT="/home/$USER/go"
export GOPATH="/home/$USER/go/packages"
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
\n'

printf "You are ready to Go!\n";
go version

Node

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash
nvm install node
nvm install 16
nvm use 16
nvm -v

Add the following to .bashrc or .zshrc:

export NVM_DIR="/home/$USER/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  # This loads nvm

ZSH

sudo apt-get install -y zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

# Set zsh as the default shell
chsh -s $(which zsh)

ZSH resources:

Antigen

See this guide for instructions.

# Install the antigen plugin manager
curl -L git.io/antigen > antigen.zsh
sudo apt-get install zsh-antigen

# Load Antigen
source "/path-to-your/antigen.zsh"

# Load Antigen configurations
antigen init ~/.antigenrc

# Turn on an Oh my Zsh plugin
antigen bundle plugin-name
antigen bundle git
antigen bundle command-not-found
antigen bundle docker

# Apply an Oh my Zsh theme
antigen theme theme-name
antigen theme robbyrussell

Example .antigenrc file:

# Load oh-my-zsh library
antigen use oh-my-zsh

# Load bundles from the default repo (oh-my-zsh)
antigen bundle git
antigen bundle command-not-found
antigen bundle docker

# Load bundles from external repos
antigen bundle zsh-users/zsh-completions
antigen bundle zsh-users/zsh-autosuggestions
antigen bundle zsh-users/zsh-syntax-highlighting

# Select theme
antigen theme denysdovhan/spaceship-prompt

# Tell Antigen that you're done
antigen apply

Starship for ZSH

See Starship: Cross-Shell Prompt.

# Install Starship
curl -sS https://starship.rs/install.sh | sh

Add the following to your .zshrc file:

eval "$(starship init zsh)"

Oh My Git

Install fonts

Before you can use Oh My Git, you need to install the terminal fonts it uses.

  1. Download the terminal fonts: git clone [email protected]:gabrielelana/awesome-terminal-fonts.git
  2. Copy all the fonts from ./build directory to ~/.fonts directory
  3. Copy all the font maps (all *.sh files) from ./build directory to ~/.fonts directory
  4. Run fc-cache -fv ~/.fonts to let freetype2 know of those fonts
  5. Customize the configuration file ./config/10-symbols.conf replacing PragmataPro with the name of the font you want to use in the terminal (I will add more fonts in the future so that this step could be skippable)
  6. Copy the above configuration file to ~/.config/fontconfig/conf.d directory
  7. Source the font maps (source ~/.fonts/*.sh) in your shell startup script (eg. ~/.bashrc or ~/.zshrc)

Install Oh My Git

git clone https://github.com/arialdomartini/oh-my-git.git ~/.oh-my-git && echo source ~/.oh-my-git/prompt.sh >> ~/.zshrc

Install for ZSH

antigen use oh-my-zsh
antigen bundle arialdomartini/oh-my-git
antigen theme arialdomartini/oh-my-git-themes oppa-lana-style

Vim (build from source)

If you run into trouble, see Vim’s official website, the installation wiki, this StackExchange answer, Building Vim from source, and the INSTALL.md instructions.

See https://github.com/akrawchyk/awesome-vim for tips, resources, and tools.

Build Vim from source

Follow these instructions to upgrade to the latest version of Vim by building the package from source. Building from source is the best (and most secure) way to get the latest version of Vim. Although many Linux operating systems come with Vim, it's usually at least a few versions behind, and they don't update it often.

  1. Install all the prerequisite libraries:
sudo apt install -y libncurses5-dev libgtk2.0-dev libatk1.0-dev libcairo2-dev libx11-dev libxpm-dev libxt-dev ruby-dev lua5.2 liblua5.2-dev libperl-dev git
  1. Remove any existing installations of Vim (and associated packages):
sudo apt remove vim vim-runtime gvim vim-tiny vim-common vim-gui-common vim-nox
  1. Download the Vim source files to your home directory:
cd ~ && git clone https://github.com/vim/vim.git && cd vim
  1. Configure the Vim source files to your liking:
./configure --with-features=huge --enable-multibyte --enable-rubyinterp=yes --enable-python3interp=yes --with-python3-config-dir=$(python3-config --configdir) --enable-perlinterp=yes --enable-luainterp=yes --enable-gui=gtk2 --enable-cscope

Or edit the make file in src. 5. Install Vim with checkinstall:

sudo apt install checkinstall
cd ~/vim
sudo checkinstall
  1. Check to make sure you installed Vim successfully:
vim --version

For more information on building Vim from source, see Vim: Compiling How To.

Tips

  • Make sure to install the silver searcher tool if you're using the fzs plugin for Vim: ` apt-get install silversearcher-ag.

Shortcuts

  • Deleting
    • To delete a single line, navigate to the line, then type dd in normal mode.
    • To delete multiple lines, navigate to the first line you want to delete, then type dd + the number of lines to delete. For example, to delete 3 lines, type dd3.
    • To delete all lines, type :%d in normal mode.
    • To delete a range of lines by line number, type :[start_line],[end_line]d. For example, to delete lines 32 through 96, type :32,96d.
    • To delete the last line, type :$d
    • To delete all lines before the current line, type :1,.-1d.
    • To delete all lines after the current line, type :.+1,$d.
  • You can use regular expression to perform actions, such as deletion, on matches. For example, to delete all lines that start with the letter 'A', type :g/^A/d.
  • To search for a word, type / then the word. For example, /crabcake.
  • g to go to the top of the file.
  • P to paste before the cursor position and p to paste after the cursor position.
  • Jump to previous location: Ctrl + I and Ctrl + O
  • ~ to change the case of highlighted text.
  • u to undo.
  • . to repeat the last action.
  • y to yank (copy) the selected text and yy to yank the current line.
  • MACROS
    • Start reporting a macro named "a": qa
    • Stop recording: q
    • Play back the macro named "a": @a
  • To search for a something in a code base, type :Ag <searchTerm>. Ag is the chemical symbol of silver because the plugin that adds this functionality is named The Silver Searcher.
  • To read the Go documentation for a method, move your cursor to the method, then type :GoDoc.
  • To navigate to a specific code line, type gg + the code line number (e.g., gg12 for line 12).
  • Use :e to reload the Vim gutter to clear the console of errors

Plugins

Code of Completion (COC) notes

  • COC default preferences: schema.json
  • To access the COC configuration file, use the Vim command :CocConfig
  • To install COC plugins, use the Vim command: :CocInstall <plugin> (e.g., :CocInstall coc-json & :CocInstall coc-tsserver )

Set Vim as the default editor

sudo update-alternatives --install /usr/bin/editor editor /usr/local/bin/vim 1
sudo update-alternatives --set editor /usr/local/bin/vim
sudo update-alternatives --install /usr/bin/vi vi /usr/local/bin/vim 1
sudo update-alternatives --set vi /usr/local/bin/vim

Java

See How To Install Java with Apt on Ubuntu 18.04 | DigitalOcean.

sudo apt install -y default-jre
sudo apt install -y openjdk-11-jre-headless
sudo apt install -y openjdk-8-jre-headless

sudo apt install -y default-jdk

java -version
javac -version

Copy the path from your preferred installation. Then open /etc/environment using nano or your favorite text editor:

sudo nano /etc/environment

At the end of this file, add the following line, making sure to replace the highlighted path with your own copied path, but do not include the bin/ portion of the path:

JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64"

Modifying this file will set the JAVA_HOME path for all users on your system.

Save the file and exit the editor.

Now reload this file to apply the changes to your current session:

source /etc/environment

Verify that the environment variable is set:

echo $JAVA_HOME

Misc applications

sudo apt install -y vlc
sudo apt install -y gimp
sudo apt install -y blender
sudo apt install -y github-desktop
sudo apt install -y steam
sudo apt install -y synaptic
sudo apt install -y timeshift

flatpak install com.discordapp.Discord -y
flatpak install pycharm-community -y


# Install bashtop (htop alternative)
sudo add-apt-repository ppa:bashtop-monitor/bashtop && sudo apt update
sudo apt install bashtop -y

# Install VS Code
sudo apt-get install -y 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
sudo sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'
rm -f packages.microsoft.gpg
sudo apt install -y apt-transport-https
sudo apt update
sudo apt install -y code

# Install ugit to undo git commands
sh -c "$(curl -fsSL https://raw.githubusercontent.com/Bhupesh-V/ugit/master/install)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment