2023 setup commands to get the windows and wsl ubuntu partition setup with needed software and settings.
After logging on and downloading chrome, check for Windows updates. This might take a bit.
Let's enable some things so we can use Andrie's trick for using scoop, choco to install software. Basically stuff you would do in linux you do with scoop.
All of these are run from powershell:
# Optional: Needed to run a remote script the first time
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
# Install
irm get.scoop.sh | iex
Then install the things:
scoop install git qpdf syncthing starship chezmoi
scoop bucket add r-bucket [https://github.com/cderv/r-bucket.git](https://github.com/cderv/r-bucket.git)
scoop install rig quarto
followed by getting R:
rig add release
rig add devel
rig add rtools
We can use rig to install multiple and switch between R versions.
scoop search rstudio
scoop install rstudio-daily-electron
scoop install rtools tinytex
scoop install python
Now let's set up Chocolatey. In general Scoop >> choco, but not everything is in scoop.
For chocolatey, open an elevated terminal (right click on powershell run as administrator):
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('[https://chocolatey.org/install.ps1'))](https://chocolatey.org/install.ps1')))
For some reason choco was already installed on windows 11 for me, so we can just use it now:
choco --help
choco list
choco search gimp
choco install audioswitcher sudo lastpass dropbox google-drive-file-stream visualstudiocode notepadplusplus vim 7zip autohotkey wincompose xplorer2 slack ditto obsidian garmin-express xplorer2ultimate -y
choco install gitkraken windirstat inkscape gimp shotcut screentogif fsviewer sumatrapdf docker-desktop zoom logitech-camera-settings -y
choco install rapidee -y
choco install winscp qpdf ghostscript inconsolata rpi-imager javaruntime -y
When it's time (periodically), upgrade all the things:
choco upgrade all -y
Winget is the microsoft supported package manager, we can also use it to install some things:
Winget:
winget install Miro.Miro
winget install Google.AndroidStudio
winget install Node.js
There are a couple more software to install / modify: Chrome, slack, obsidian, git, RStudio, discord, spotify, notepad++, mobaxterm, java, steam
A couple other UI things (is it possible to do this programmatically?):
- Disable notifications in all the apps (the biggest offenders are slack, discord, google)
- Configure Chrome to on startup continue where you left off.
- Set power settings to stay on if plugged in to power
- Set duck duck go to default web search: https://duckduckgo.com/
Install Python
Open windows powershell as administrator
choco install -y python3
python --version
Alternatively, Microsoft recommends installing from the Microsoft Store
Create environment: python -m venv .venv
On windows activate the environment with:
# In cmd.exe
venv\Scripts\activate.bat
# In PowerShell
venv\Scripts\Activate.ps1
Install packages with:
source .venv/bin/activate # linux
pip install --upgrade pip
python -m pip install --upgrade pip wheel setuptools
pip install -r requirements.txt
View environment with: pip list
View configuration of repositories: pip config list -v
Set repository for pip:
pip config set global.index-url <url>
pip config set global.trusted-host <url>
Exit the venv with: deactivate
Check python version, make sure it is a supported version (for example, 3.10.8): python --version
Check available python versions: ls -1d /opt/python/*
Update the alias to point towards the desired python version: alias python="/opt/python/3.10.8/bin/python3"
Save the requirements.txt file for the environment: `pip freeze > requirements.txt
Files will be saved into: \\wsl$
for example at \\wsl$\Ubuntu\home\landers\docs.rstudio.com
We also need to get set up with WSL. Install Windows Terminal (through the Microsoft Store) and go through https://code.visualstudio.com/docs/remote/wsl
For wsl, open an elevated terminal (right click on powershell run as administrator):
wsl --install
This command will enable the features necessary to run WSL and install the Ubuntu distribution of Linux.
wsl --install -d ubuntu
In the case of having multiple linux flavors installed for WSL then a default can be declared with:
wsl --set-default ubuntu
May have to follow this page to fix an error: https://learn.microsoft.com/en-us/answers/questions/1187339/resolving-error-0x80370114-the-operation-could-not
Follow the best practices for setting up wslhttps://learn.microsoft.com/en-us/windows/wsl/setup/environment#set-up-your-linux-username-and-password page.
Once the process of installing your Linux distribution with WSL is complete, open the distribution (Ubuntu by default) using the Start menu. You will be asked to create a User Name and Password for your Linux distribution. If you forget the password for your Linux distribution:
- Open PowerShell and enter the root of your default WSL distribution using the command:
wsl -u root
Update and upgrade your ubuntu wsl:
sudo apt update && sudo apt upgrade
Install system dependencies:
sudo apt install xdg-utils
Follow https://docs.docker.com/engine/install/linux-postinstall/ for Docker
Install using the apt repository:
$ sudo apt-get update
$ sudo apt-get install ca-certificates curl gnupg
# Add Docker's official GPG key:
$ sudo install -m 0755 -d /etc/apt/keyrings
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
$ sudo chmod a+r /etc/apt/keyrings/docker.gpg
# Use the following command to set up the repository:
$ echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Update the `apt` package index:
$ sudo apt-get update
# To install the latest version, run:
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
# Verify that the Docker Engine installation is successful by running the `hello-world` image.
$ sudo docker run hello-world
Also run this for docker settings if managing as a non root user: https://docs.docker.com/engine/install/linux-postinstall/
sudo groupadd docker
sudo usermod -aG docker $USER
Set up SSH keys and use with Git. Follow the instructions here.
# Make sure git is installed
git --version
# Paste the text below, substituting in your GitHub email address.
ssh-keygen -t ed25519 -C "[email protected]"
You can check that SSH keys exist and the name with:
ls ~/.ssh
ls -al ~/.ssh
See the public piece of the SSH key with:
nano /home/ubuntu/.ssh/id_ed25519.pub
Add this to your github profile under your ssh keys under Settings -> Access -> SSH and GPG keys -> New SSH key
Try cloning down a repository to test that everything has been set up correctly.
Use code . to open any cloned repo with vs code
Tip: from visual studio code press Ctrl shift ~ to access the ubuntu shell!
Install these extensions:
- wsl
- pets
Add to your .profile with sudo nano ~/.profile
aws-assume() {
role=$1 && shift
unset AWS_DEFAULT_PROFILE
export AWS_DEFAULT_PROFILE=$role
}
aws-unset() {
unset AWS_DEFAULT_PROFILE
unset AWS_DEFAULT_REGION
unset AWS_SESSION_TOKEN
unset AWS_SECRET_ACCESS_KEY
unset AWS_ACCESS_KEY_ID
}
source ~/.profile
Install: awscli from https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
sudo apt install unzip
unzip awscliv2.zip
sudo ./aws/install
To resolve the error when opening a web browser window refer to: aws/aws-cli#7892
For those who are still looking for an answer on this. You probably need to install wslu on your distro in wsl2 to stop this error and automatically launch your browser.
Run aws configure sso
to interactively create a profile in your ~/.aws/config
.
Update your profile: source ~/.profile
Test it:
aws-assume eu-west-1
aws-assume team-east-1
aws-assume team-east-2
aws sso login
aws sts get-caller-identity
Install: https://github.com/casey/just#installation
Set up the prebuilt MPR repository: https://docs.makedeb.org/prebuilt-mpr/getting-started/#setting-up-the-repository
wget -qO - 'https://proget.makedeb.org/debian-feeds/prebuilt-mpr.pub' | gpg --dearmor | sudo tee /usr/share/keyrings/prebuilt-mpr-archive-keyring.gpg 1> /dev/null
echo "deb [arch=all,$(dpkg --print-architecture) signed-by=/usr/share/keyrings/prebuilt-mpr-archive-keyring.gpg] https://proget.makedeb.org prebuilt-mpr $(lsb_release -cs)" | sudo tee /etc/apt/sources.list.d/prebuilt-mpr.list
sudo apt update
sudo apt install just
# Check that it's been added here:
/etc/apt/sources.list.d/prebuilt-mpr.list
Install: Install and Set Up kubectl on Linux https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
kubectl version --client
Configure Kubectl: Creating or updating a kubeconfig file for an Amazon EKS cluster - Amazon EKS https://docs.aws.amazon.com/eks/latest/userguide/create-kubeconfig.html
For example a workflow might look something like this:
aws eks update-kubeconfig --region region-code --name my-cluster
aws-assume staging-east-2
aws sso login
aws eks update-kubeconfig --name <redacted>
kubectl config use-context arn:aws:eks:us-east-2:<redacted>:cluster/<redacted>
Install: Helm | Installing Helm https://helm.sh/docs/intro/install/
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
helm diff plugin Install: GitHub - databus23/helm-diff: A helm plugin that shows a diff explaining what a helm upgrade would change https://github.com/databus23/helm-diff
helm plugin install https://github.com/databus23/helm-diff
helm rstudio repo
helm repo add rstudio https://helm.rstudio.com
helmfile Install: Releases · helmfile/helmfile https://github.com/helmfile/helmfile/releases
#Download the tar for your Os/Platform from this link: https://github.com/helmfile/helmfile/releases with wget {{ bin_url }} -O helmfile_linux_amd64
wget https://github.com/helmfile/helmfile/releases/download/v0.156.0/helmfile_0.156.0_linux_amd64.tar.gz -O helmfile_linux_amd64
chmod +x helmfile_linux_amd64
mv helmfile_linux_amd64 ~/.local/bin/helmfile
#Extract helmfile:
tar -xvf helmfile_0.145.3_linux_amd64.tar.gz
#Cp helmfile to Pathable location
sudo cp helmfile /usr/local/bin
On mac:
brew install pulumi/tap/pulumi
On Ubuntu/WSL:
curl -fsSL https://get.pulumi.com | sh
For other operating systems see https://www.pulumi.com/docs/install/
After installing pulumi you will need to generate a personal access token for use later through https://app.pulumi.com/account/tokens.
pulumi config set email [email protected]
Resolving the error: An error occurred (SignatureDoesNotMatch) when calling the GetCallerIdentity operation: Signature expired: 20230913T041408Z is now earlier than 20230913T143449Z (20230913T144949Z - 15 min.) Refer to: aws/aws-cli#6676 as well as aws/aws-cli#602
On an ubuntu machine:
sudo apt install ntp
sudo apt install ntpdate
sudo service ntp stop`
sudo ntpdate pool.ntp.org
sudo service ntp start
Test this by running date
in both powershell and your wsl terminal and comparing to see if they are off by more than a couple minutes.
Install additional Python options
export PYTHON_VERSION="3.10.8"
sudo apt-get install gdebi-core
curl -O https://cdn.rstudio.com/python/ubuntu-2204/pkgs/python-${PYTHON_VERSION}_1_amd64.deb
sudo gdebi python-${PYTHON_VERSION}_1_amd64.deb
PATH=/opt/python/"${PYTHON_VERSION}"/bin:$PATH
alias python="/opt/python/"${PYTHON_VERSION}"/bin/python3"
sudo apt install python3.10-venv
sudo apt install python3-pip
alias python="/opt/python/3.10.8/bin/python3"
alias python3="/opt/python/3.10.8/bin/python3"
Working inside a Python virtual environment:
cd dir/
python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip
python3 -m pip install --upgrade pip wheel setuptools
pip install -r requirements.txt
Install Jupyter
python3 -m pip install jupyter
Troubleshooting
- Check python version, make sure it is a supported version (for example, 3.10.8 worked as of 8/1/2023):
python --version
- Check available python versions:
ls -1d /opt/python/*
orwhereis python3
- (Optional) update the python alias to point towards the desired python version:
alias python="/opt/python/3.10.8/bin/python3"
- Check python packages and their versions:
pip list
- Leave a venv with:
deactivate
$ export QUARTO_VERSION="1.3.450"
$ sudo mkdir -p /opt/quarto/${QUARTO_VERSION}
$ sudo curl -o quarto.tar.gz -L \
"https://github.com/quarto-dev/quarto-cli/releases/download/v${QUARTO_VERSION}/quarto-${QUARTO_VERSION}-linux-amd64.tar.gz"
$ sudo tar -zxvf quarto.tar.gz \
-C "/opt/quarto/${QUARTO_VERSION}" \
--strip-components=1
$ sudo rm quarto.tar.gz
$ /opt/quarto/"${QUARTO_VERSION}"/bin/quarto check
$ sudo ln -sf /opt/quarto/${QUARTO_VERSION}/bin/quarto /usr/local/bin/quarto
sudo apt-get update
sudo apt-get install gdebi-core
export R_VERSION=4.2.3
curl -O https://cdn.rstudio.com/r/ubuntu-2204/pkgs/r-${R_VERSION}_1_amd64.deb
sudo gdebi r-${R_VERSION}_1_amd64.deb
/opt/R/${R_VERSION}/bin/R --version
sudo ln -s /opt/R/${R_VERSION}/bin/R /usr/local/bin/R
sudo ln -s /opt/R/${R_VERSION}/bin/Rscript /usr/local/bin/Rscript
sudo rm r-${R_VERSION}_1_amd64.deb
Install some packages
sudo R
install.packages("rmarkdown")
Dot files from cole and david: