Reinstall Linux

Regularly happens

Page content

Need to have some standard post-install task sequence for the reference, so recording it here.

Very empty ubuntu tesktop

Where

Usually I use ubuntu-based distros. The most recent install is Mint 21.3 (based on ubuntu 22.04).

How

some lovely tools

sudo apt-get install git git-lfs gimp mc flameshot htop nvtop

# if graphic work is on the horizon
sudo apt-get install imagemagick
git lfs install

# if some pdf manipulation required
sudo apt-get install poppler-utils

json manipulation

Examples see in Bash Cheat Sheet

sudo apt-get install jq jo

Install NVidia drivers

Method 1

Remove local NVidia drivers

sudo apt-get purge 'nvidia*'
sudo apt-get autoremove
sudo apt-get autoclean

Add PPA and update local package refs

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update

Check which driver version NVidia recomments for your device

ubuntu-drivers devices

Install it

sudo apt-get install nvidia-driver-535
sudo reboot

Check that you can see your GPU, and see which version is installed

nvidia-smi

Method 2

See here for your OS version: https://developer.nvidia.com/cuda-downloads

To install the open kernel module flavor:

sudo apt-get install -y nvidia-driver-555-open
sudo apt-get install -y cuda-drivers-555

Install CUDA

The same NVidia official: https://developer.nvidia.com/cuda-downloads

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-ubuntu2204.pin
sudo mv cuda-ubuntu2204.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/12.5.0/local_installers/cuda-repo-ubuntu2204-12-5-local_12.5.0-555.42.02-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu2204-12-5-local_12.5.0-555.42.02-1_amd64.deb
sudo cp /var/cuda-repo-ubuntu2204-12-5-local/cuda-*-keyring.gpg /usr/share/keyrings/
sudo apt-get update
sudo apt-get -y install cuda-toolkit-12-5

flatpacks

vlc, obsidian, nextcloud desktop, foliate, dbeaver

ungoogled-chromium

https://github.com/ungoogled-software/ungoogled-chromium

echo 'deb http://download.opensuse.org/repositories/home:/ungoogled_chromium/Ubuntu_Jammy/ /' | sudo tee /etc/apt/sources.list.d/home:ungoogled_chromium.list
curl -fsSL https://download.opensuse.org/repositories/home:ungoogled_chromium/Ubuntu_Jammy/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/home_ungoogled_chromium.gpg > /dev/null
sudo apt update
sudo apt install ungoogled-chromium

golang

This one installs quite an old version, currently 1.18

sudo apt-get install golang-go

so, goto https://go.dev/dl/ and pick your latest version, then,

sudo bash

and

wget https://go.dev/dl/go1.22.4.linux-amd64.tar.gz
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.22.4.linux-amd64.tar.gz

then add to $HOME/.profile

export PATH=$PATH:/usr/local/go/bin

then

source $HOME/.profile
go version

vs code

https://code.visualstudio.com/docs/setup/linux

Install deb package (need to download it first). Installing the .deb package will automatically install the apt repository and signing key to enable auto-updating using the system’s package manager.

Or do the same manually below below:

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

Then update the package cache and install the package using:

sudo apt install apt-transport-https
sudo apt update
sudo apt install code # or code-insiders

Install vs code extensions:

Python, C#, Go, Hugohelper, Front Matter CMS, React*, [Flutter](https://www.glukhov.org/post/2022/flutter-dart-cheatsheet/ “Flutter (Dart) Cheatsheet with exampl etc

Standard vscode has some telemetry - partially removed in settings:user:application:telemetry=>off … but still …

VSCodium flatpack is telemetry-less version, not very much behind.

Python and Anaconda

Install pip

sudo apt install python3-pip

https://www.anaconda.com/download/success

download linux version like

wget https://repo.anaconda.com/archive/Anaconda3-2024.06-1-Linux-x86_64.sh

and execute it

bash Anaconda3-2024.06-1-Linux-x86_64.sh

pay attention in the end:

If you'd prefer that conda's base environment not be activated on startup,
   run the following command when conda is activated:

conda config --set auto_activate_base false

You can undo this by running `conda init --reverse $SHELL`? [yes|no]

hugo

https://gohugo.io/installation/linux/

for example this: https://github.com/gohugoio/hugo/releases/tag/v0.124.1

download and install hugo_extended_0.124.1_linux-amd64.deb

kubectl

https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/#install-using-native-package-management

sudo apt-get update
# apt-transport-https may be a dummy package; if so, you can skip that package
sudo apt-get install -y apt-transport-https ca-certificates curl
# If the folder `/etc/apt/keyrings` does not exist, it should be created before the curl command, read the note below.
# sudo mkdir -p -m 755 /etc/apt/keyrings
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.29/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
sudo chmod 644 /etc/apt/keyrings/kubernetes-apt-keyring.gpg # allow unprivileged APT programs to read this keyring
# This overwrites any existing configuration in /etc/apt/sources.list.d/kubernetes.list
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.29/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo chmod 644 /etc/apt/sources.list.d/kubernetes.list   # helps tools such as command-not-found to work correctly
sudo apt-get update
sudo apt-get install -y kubectl

ssh keys

copy ssh keys to ~/.ssh

then copy id to all ipaddrs in your lab

ssh-copy-id username@ipaddr

docker

sudo docker images

uninstall existing

for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done

Install using the apt repository

# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

if you use ubuntu deriviatives you need to use UBUNTU_CODENAME instead VERSION_CODENAME, like

# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "$UBUNTU_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

Install the latest version:

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

Verify

sudo docker run hello-world

Optionally, add current user to docker group

usermod -aG docker $USER

portainer

To get started, you will need:

  • The latest version of Docker installed and working
  • sudo access on the machine that will host your Portainer Server instance
  • By default, Portainer Server will expose the UI over port 9443 and expose a TCP tunnel server over port 8000. The latter is optional and is only required if you plan to use the Edge compute features with Edge agents.

reqs:

  • SELinux is disabled on the machine running Docker. If you require SELinux, you will need to pass the –privileged flag to Docker when deploying Portainer.

First, create the volume that Portainer Server will use to store its database:

sudo docker volume create portainer_data

Then, download and install the Portainer Server container:

sudo docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest

check

sudo docker ps

Navigate to: https://localhost:9443

Username is admin, set the password in ui

Kubernetes portainer agent

Create k8s environment, agent

kubectl apply -f https://downloads.portainer.io/ce2-19/portainer-agent-k8s-lb.yaml
kubectl get services --all-namespaces

then copy paste extenal ip address of the portainer service into ui, don’t forget the port 9001

.netcore sdk

https://learn.microsoft.com/en-gb/dotnet/core/install/linux-ubuntu-install?tabs=dotnet8&pivots=os-linux-ubuntu-2204

sudo apt-get update && \
  sudo apt-get install -y dotnet-sdk-8.0 aspnetcore-runtime-8.0

or

sudo apt-get update && \
  sudo apt-get install -y dotnet-sdk-8.0 dotnet-runtime-8.0

Dependencies

When you install with a package manager, these libraries are installed for you. But, if you manually install .NET or you publish a self-contained app, you’ll need to make sure these libraries are installed:

  • libc6
  • libgcc-s1
  • libgssapi-krb5-2
  • libicu70
  • liblttng-ust1
  • libssl3
  • libstdc++6
  • libunwind8
  • zlib1g

Dependencies can be installed with the apt install command. The following snippet demonstrates installing the zlib1g library:

sudo apt install zlib1g

awscli

To install awscli from the ubuntu repository (in July 2024 it gets you v1.22.34-1):

sudo apt install awscli

To check awscli version installed on your pc:

aws --version

Or to get the most up-to-date version freshly baked by Amazon (2.0): https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html

currently:

curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install --bin-dir /usr/local/bin --install-dir /usr/local/aws-cli --update

Terraform

Terraform can be installed in many ways, see here: https://developer.hashicorp.com/terraform/install

I’m installinf from hashicorp’s repo for ubuntu

wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update && sudo apt install terraform

And for linux mint be carefull, the terraform installer doesn’t work correctly. Check outputs of these to commands

lsb_release -cs

cat /etc/upstream-release/lsb-release 

Now go to Software Sources and replace in Hashicorp the ‘virginia’ with ‘Jammy’ and run again

sudo apt update && sudo apt install terraform

To check that terraform is installed correctly, execute

terraform version