Last active
June 23, 2022 01:06
-
-
Save ndamulelonemakh/d2e1439c006e7825ca2cd1c42ce2037f to your computer and use it in GitHub Desktop.
WSL2 setup on a new Windows 11 PC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Most of the commands are based on this tutorial: https://www.sitepoint.com/wsl2/ | |
| # Step 1: Windows pre-requisites | |
| # Official guide: https://docs.microsoft.com/en-us/windows/wsl/install-manual | |
| # Run the following commands in Powershell(as admin) | |
| dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart | |
| dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart | |
| # Download and Run: https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi | |
| wsl --set-default-version 2 | |
| # Step 2: Install linux distro of your choice | |
| wsl --install -d ubuntu | |
| # make sure you have the latest package updates | |
| sudo apt-get update | |
| sudo apt-get upgrade | |
| sudo apt-get dist-upgrade | |
| sudo apt-get autoremove | |
| # Step 3: Move installation to secondary drive(to save space!) | |
| mkdir D:\backup | |
| wsl --export Ubuntu D:\backup\ubuntu.tar | |
| wsl --unregister Ubuntu | |
| mkdir D:\wsl | |
| wsl --import Ubuntu D:\wsl\ D:\backup\ubuntu.tar | |
| # change default user from root to your name | |
| ubuntu2004.exe config --default-user $USER | |
| # Step 4(Optional): Enable GUI support | |
| # Add this line to .bashrc or .profile | |
| # export DISPLAY=$(route.exe print | grep 0.0.0.0 | head -1 | awk '{print $4}'):0.0 | |
| # Above steps are not required on the latest update: https://docs.microsoft.com/en-us/windows/wsl/tutorials/gui-apps | |
| wsl --update | |
| wsl --shutdown | |
| # Install example gui app | |
| sudo apt install gimp -y | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment