Skip to content

wsl2 + Ubuntu

License

Notifications You must be signed in to change notification settings

aubique/dotfiles-wsl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

22 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

WSL2 Ubuntu Environment

GitHub license GitHub stars GitHub commits

About β€’ Windows 11 β€’ Chocolatey β€’ Ubuntu β€’ Todo

About

Personal dotfiles for setting up a development environment on Windows 11 using WSL2 with Ubuntu. Primary development tools:

  • VSCode
  • Windows Terminal

Windows 11

Download Sophia Script:

iwr script.sophia.team -useb | iex

Run customized preset (as Administrator):

Set-ExecutionPolicy Bypass -Scope Process -Force; (New-Object System.Net.WebClient).DownloadString('https://gist.githubusercontent.com/aubique/871ad87ef7a801d17942ca3974cd9909/raw/e7d2d14297f6b098972dae0213f0072716b6a186/Sophie.ps1') | Out-File .\Sophie.ps1; .\Sophie.ps1

2. WSL2

After restart, install Ubuntu:

wsl --install -d Ubuntu

3. Dotfiles

Download and unpack dotfiles:

git clone --separate-git-dir=$HOME/.dotfiles https://github.com/aubique/dotfiles-wsl.git /tmp/tmpdotfiles \
&& rsync -vah --exclude '.git' /tmp/tmpdotfiles/ $HOME/ \
&& sudo rsync -vah $HOME/pub/etc/ /etc/

Run, configure and clean dotfiles:

for s in source "/etc/profile" "$HOME/.profile"; do source $s; done \
&& dotfiles config status.showUntrackedFiles no \
&& rm -r /tmp/tmpdotfiles \
&& cd $HOME \
&& dotfiles submodule update --init

4. User Shell Folders

Relocate default Windows shell folders (Documents, Downloads, etc.) to a dedicated partition while adopting Linux FHS structure:

bash $RUNSCRIPTS_PATH/relocate_user_shell_folders.sh

Features:

  • Moves user folders to new partition/drive πŸ—‚οΈ
  • Symlinks WSL $HOME directories to Windows shell folders πŸ”—
  • Updates Windows PATH with new locations for cross-system access βš™οΈ
  • Maintains Linux-style directory hierarchy (/etc, /usr/local, etc.) 🐧

Package Management

Install Chocolatey:

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

Install Windows apps and tools:

Get-Content \\wsl$\Ubuntu\home\*\pub\pkglist_choco.txt | Select-String -NotMatch '^#.*' | ForEach {iex "choco install -y $_"}
πŸ› οΈ Post-Install Tweaks

VLC

Remove VLC Media Player Context Entries (as Administrator):

New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
Remove-Item HKCR:\Directory\shell\AddToPlaylistVLC\, HKCR:\Directory\shell\PlayWithVLC\ -Recurse

7-Zip

To simplify 7-Zip Context Menu open 7-Zip GUI (as Administrator):

Tools β†’ Options β†’ 7-Zip β†’ [Uncheck Integrate to shell context menu]

WSL2 Ubuntu

Install required Ubuntu apt-packages:

sudo apt update && grep -vE '^#' ~/pub/pkglist_apt.txt | xargs sudo apt install -y

Dev Setup

Git

Basic Git configuration:

git config --global push.default current
git config --global core.pager /usr/bin/less

Set username and email:

git config --global user.email "{{EMAIL}}"
git config --global user.name "{{USERNAME}}"

SSH

Generate SSH key:

ssh-keygen -t ed25519 -C "$(hostname | sed 's/^DESKTOP-//; s/.*/\L&/'):$(date -I)" -f ~/.ssh/id_ed25519_serv-user

GitHub / GitLab

Copy SSH key to clipboard and add it:

xclip -sel c < ~/.ssh/id_ed25519_gl-user.pub

Remove any previous Docker installations:

sudo apt remove docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc

Add Docker's official GPG key:

sudo apt install -y ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo tee /etc/apt/keyrings/docker.asc > /dev/null
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

Install Docker packages:

sudo apt update && sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Run Docker without sudo:

sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker

Verify installation:

docker run hello-world

Install Volta, Node version manager:

mkdir -p $VOLTA_HOME
curl https://get.volta.sh | bash -s -- --skip-setup

Then install package managers and Angular:

volta install node npm @angular/cli

Install SDKMan, Java version manager:

curl -sSL "https://get.sdkman.io?rcupdate=false" | bash

Then install JDK 21 of Eclipse Temurin (formerly AdoptOpenJDK):

sdk install java 21.0.5-tem

GPG keys

If you have GPG keys for signing commits or password manager, backup to restore them on the new machine:

gpg --list-secret-keys
gpg --export-secret-keys {{KEY_ID}} > /tmp/private.key

Verify permissions for gnupg:

gpg --card-status

If you have "Permission Denied" problem, type:

mkdir -pv ~/.config/gnupg
find $GNUPGHOME -type d -exec sudo chown $USER:$USER {} \; -exec chmod 700 {} \;
find $GNUPGHOME -type f -exec sudo chown $USER:$USER {} \; -exec chmod 600 {} \;

Import GPG keys for signing:

gpg --import /tmp/private.key

Troubleshooting

If you have problem with clipboard, for example when typing echo foobar | wl-copy, then you need to run:

sudo chmod +rx /mnt/wslg/runtime-dir
ln -s /mnt/wslg/runtime-dir/wayland-0* /run/user/1000/

TODO

  • Upgrade Windows Tweaks
  • Decouple relocate_user_shell_folders.sh from gist