Difference between revisions of "Wsl"
Jump to navigation
Jump to search
(13 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | # Getting started | ||
+ | |||
+ | # Enable wsl on windows from powershell | ||
+ | ``` | ||
+ | wsl --install | ||
+ | computer-restart | ||
+ | wsl.exe --list --online | ||
+ | |||
+ | wsl --set-default-version 1 | ||
+ | wsl --install -d Ubuntu-22.04 | ||
+ | wsl.exe --setdefault Ubuntu-22.04 | ||
+ | bash | ||
+ | ``` | ||
+ | |||
+ | # Prep for k8s | ||
+ | ``` | ||
+ | sudo apt update && sudo apt -y install unzip | ||
+ | curl -LO https://github.com/Azure/kubelogin/releases/download/v0.0.29/kubelogin-linux-amd64.zip | ||
+ | unzip kubelogin-linux-amd64.zip | ||
+ | sudo cp bin/linux_amd64/kubelogin /usr/local/bin/ | ||
+ | |||
+ | curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash | ||
+ | ``` | ||
+ | |||
+ | ## VPN Issues | ||
+ | - https://github.com/sakai135/wsl-vpnkit | ||
+ | |||
+ | ## Docs | ||
+ | - https://learn.microsoft.com/en-us/windows/wsl/install | ||
+ | - https://learn.microsoft.com/en-us/windows/wsl/basic-commands | ||
+ | |||
+ | # Use vbox not hyper-v | ||
+ | |||
+ | bcdedit /set hypervisorlaunchtype off | ||
+ | |||
+ | https://stackoverflow.com/questions/58031941/how-to-get-virtualbox-6-0-and-wsl-working-at-the-same-time | ||
+ | |||
+ | ## Install | ||
+ | |||
+ | |||
+ | |||
``` | ``` | ||
curl.exe -LO https://cloud-images.ubuntu.com/wsl/jammy/current/ubuntu-jammy-wsl-amd64-wsl.rootfs.tar.gz | curl.exe -LO https://cloud-images.ubuntu.com/wsl/jammy/current/ubuntu-jammy-wsl-amd64-wsl.rootfs.tar.gz | ||
wsl.exe --import jammy jammyFolder .\ubuntu-jammy-wsl-amd64-wsl.rootfs.tar.gz | wsl.exe --import jammy jammyFolder .\ubuntu-jammy-wsl-amd64-wsl.rootfs.tar.gz | ||
# 20.04 and older https://cloud-images.ubuntu.com/releases/ | # 20.04 and older https://cloud-images.ubuntu.com/releases/ | ||
− | wsl --setdefault jammy | + | wsl.exe --setdefault jammy |
+ | wsl.exe -l -v | ||
+ | ``` | ||
+ | |||
+ | ## add sudo user | ||
+ | ``` | ||
+ | wsl -d jammy | ||
+ | adduser myuser | ||
+ | ``` | ||
+ | |||
+ | nano /etc/sudoers.d/myuser | ||
+ | ``` | ||
+ | myuser ALL=(ALL) NOPASSWD:ALL | ||
+ | ``` | ||
+ | ``` | ||
+ | exit | ||
+ | wsl --user myuser -d jammy | ||
``` | ``` | ||
Line 9: | Line 66: | ||
https://gist.github.com/ScriptAutomate/f94cd44dacd0f420fae65414e717212d?permalink_comment_id=3627426 | https://gist.github.com/ScriptAutomate/f94cd44dacd0f420fae65414e717212d?permalink_comment_id=3627426 | ||
+ | ``` | ||
+ | wsl -l -v | ||
+ | wsl --set-default-version 2 | ||
+ | wsl --install -d ubuntu | ||
+ | |||
+ | wsl --terminate my-name | ||
+ | wsl --set-version Ubuntu-20.04 2 | ||
+ | ``` | ||
``` | ``` | ||
Line 33: | Line 98: | ||
# Share keys | # Share keys | ||
https://devblogs.microsoft.com/commandline/sharing-ssh-keys-between-windows-and-wsl-2/ | https://devblogs.microsoft.com/commandline/sharing-ssh-keys-between-windows-and-wsl-2/ | ||
+ | |||
+ | |||
+ | ``` | ||
+ | netsh winsock reset | ||
+ | netsh int ip reset all | ||
+ | netsh winhttp reset proxy | ||
+ | ipconfig /flushdns | ||
+ | ``` | ||
+ | |||
+ | # Customizations | ||
+ | |||
+ | ## Set Default User | ||
+ | ``` | ||
+ | sudo vim /etc/wsl.conf | ||
+ | [user] | ||
+ | default=myuser | ||
+ | exit | ||
+ | wsl --terminate Ubuntu | ||
+ | bash | ||
+ | ``` | ||
+ | |||
+ | ## No sudo pass | ||
+ | ``` | ||
+ | sudo visudo | ||
+ | myuser ALL=(ALL) NOPASSWD:ALL | ||
+ | ``` |
Latest revision as of 18:15, 18 May 2023
Getting started
Enable wsl on windows from powershell
wsl --install computer-restart wsl.exe --list --online wsl --set-default-version 1 wsl --install -d Ubuntu-22.04 wsl.exe --setdefault Ubuntu-22.04 bash
Prep for k8s
sudo apt update && sudo apt -y install unzip curl -LO https://github.com/Azure/kubelogin/releases/download/v0.0.29/kubelogin-linux-amd64.zip unzip kubelogin-linux-amd64.zip sudo cp bin/linux_amd64/kubelogin /usr/local/bin/ curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
VPN Issues
Docs
- https://learn.microsoft.com/en-us/windows/wsl/install
- https://learn.microsoft.com/en-us/windows/wsl/basic-commands
Use vbox not hyper-v
bcdedit /set hypervisorlaunchtype off
Install
curl.exe -LO https://cloud-images.ubuntu.com/wsl/jammy/current/ubuntu-jammy-wsl-amd64-wsl.rootfs.tar.gz wsl.exe --import jammy jammyFolder .\ubuntu-jammy-wsl-amd64-wsl.rootfs.tar.gz # 20.04 and older https://cloud-images.ubuntu.com/releases/ wsl.exe --setdefault jammy wsl.exe -l -v
add sudo user
wsl -d jammy adduser myuser
nano /etc/sudoers.d/myuser
myuser ALL=(ALL) NOPASSWD:ALL
exit wsl --user myuser -d jammy
https://gist.github.com/ScriptAutomate/f94cd44dacd0f420fae65414e717212d?permalink_comment_id=3627426
wsl -l -v wsl --set-default-version 2 wsl --install -d ubuntu wsl --terminate my-name wsl --set-version Ubuntu-20.04 2
wsl -d ubuntu-20.04 -u myuser -- bash wsl -d ubuntu-20.04 -- bash
/etc/wsl.conf
[user] default=myuser [automount] options = "metadata"
restart wsl
wsl --shutdown
- https://stackoverflow.com/questions/46610256/chmod-wsl-bash-doesnt-work
- https://superuser.com/questions/1337153/change-home-of-wsl-to-mnt-c-users-yourwindowsuser
https://devblogs.microsoft.com/commandline/sharing-ssh-keys-between-windows-and-wsl-2/
netsh winsock reset netsh int ip reset all netsh winhttp reset proxy ipconfig /flushdns
Customizations
Set Default User
sudo vim /etc/wsl.conf [user] default=myuser exit wsl --terminate Ubuntu bash
No sudo pass
sudo visudo myuser ALL=(ALL) NOPASSWD:ALL