# Set Up Ubuntu in WSL 2 I regularly use Windows Subsystem for Linux (WSL 2, the second generation that is based on virtualization) for personal projects and work. My typical use cases include: * Software Development (C, Fortran, Python) * Parallel Programming (MPI, OpenMP) * Scientific Data Analysis and Visualization (Python) I prefer Debian-based Linux distributions (e.g., Debian, Ubuntu). ----- 1. Install WSL 2 and a Linux distribution of your choice directly via command line. ```bash wsl --list --online wsl --install Ubuntu-24.04 --location "D:\WSL2\Ubuntu-24.04" --no-launch ``` Specify a custom installation path (e.g., `D:\WSL2\Ubuntu-24.04`) via `--location` to save space on `C:\`. 2. Upgrade and install packages. ```bash sudo add-apt-repository -y ppa:kisak/turtle sudo apt update sudo apt upgrade -y sudo apt install -y \ binutils build-essential gcc g++ gfortran autoconf automake libtool gdb \ diffstat diffutils git git-lfs make patch patchutils pkgconf \ bash-completion coreutils less man-db perl procps psmisc python3 python3-pip python3-venv tcsh time tmux vim \ bind9-dnsutils ca-certificates curl hostname iputils-* ncat ndiff netcat-openbsd nmap rsync ssh traceroute wget \ bzip2 gzip lz4 unzip xz-utils zip zstd \ mesa-utils qt6-wayland x11-apps x11-utils xauth xterm CMAKE_VERSION="3.31.12" wget -O "CMake-${CMAKE_VERSION}.tar.gz" "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-x86_64.tar.gz" sudo tar -xf "CMake-${CMAKE_VERSION}.tar.gz" -C "/usr/local" --no-same-owner --strip-components=1 ``` Some [platform dependencies](https://doc.qt.io/qt-6/linux-requirements.html) are required for enabling the [`QtAgg` backend](https://matplotlib.org/stable/users/explain/figure/backends.html) in `matplotlib`. It draws figures much faster than the basic `TkAgg` backend. 3. Install [Miniforge](https://github.com/conda-forge/miniforge/releases/latest) (Mambaforge and Miniforge have converged and are now identical!). ```bash wget "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh" bash "Miniforge3-$(uname)-$(uname -m).sh" -b miniforge3/bin/conda init bash miniforge3/bin/mamba shell init --shell bash ``` Log out and log in again. Then, * Do not activate the `base` environment automatically. ```bash conda config --set auto_activate false ``` * Update the `base` environment. ```bash mamba update conda mamba mamba update --all ``` * Set up additional [Conda Environments](https://hackmd.io/@stargazerwang/SJOFRPT01x). 4. Set up [Dot Files](https://hackmd.io/@stargazerwang/HkYFVktlY). 5. Install [Docker Engine](https://hackmd.io/@stargazerwang/S1Wao5ZVn). 6. Install [Lmod](https://hackmd.io/@stargazerwang/ryOsp7F4T). 7. Install [Intel oneAPI Compilers](https://hackmd.io/@stargazerwang/B1g55BLpA).