Skip to content

Instantly share code, notes, and snippets.

@wesleyav
Last active February 6, 2024 21:53
Show Gist options
  • Save wesleyav/d2fb34625b1571e595ef82dc0e4293d4 to your computer and use it in GitHub Desktop.
Save wesleyav/d2fb34625b1571e595ef82dc0e4293d4 to your computer and use it in GitHub Desktop.
ambiente-dev-wsl2

Ambiente de desenvolvimento WSL2

  • Windows 10 Versão 22H2 (Compilação 19045.3996)

No PowerShell como ADM

# instala wsl (por padrão instala Ubuntu)
wsl --install

## define como padrão a versão 2 do wsl
wsl --set-default-version 2

# exibe lista válida de distribuições
wsl --list --online

# instala wsl com distribuição específica
wsl --install Debian
wsl --install Ubuntu

# exibe as distribuições Linux instaladas
wsl --list --verbose ou wsl -l

# define distribuição padrão do Linux
wsl --set-default Ubuntu

# atualiza wsl
wsl --update

# reinicializa wsl
wsl --shutdown

# remove uma distribuição Linux do WSL
wsl --unregister Ubuntu

# altera a versão de uma distribuição do Linux de WSL 1 para WSL 2
wsl --set-version Ubuntu 2

Definindo limites no WSL

Criar um arquivo chamado .wslconfig em (C:\Users<usuario>) e definir as configurações:

[wsl2]
memory=6GB
processors=4
swap=2GB

Configurando Windows Terminal

Instalar via Microsoft Store

Configurando profile

Windows Terminal > Configurações > Perfis > Ubuntu

  • linha de comando: wsl -d Ubuntu
  • diretório inicial: \\wsl$\Ubuntu\home\user
{
    "commandline": "wsl -d Ubuntu",
    "guid": "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}",
    "hidden": false,
    "name": "Ubuntu",
    "source": "CanonicalGroupLimited.Ubuntu_79rhkp1fndgsc",
    "startingDirectory": "\\\\wsl$\\Ubuntu\\home\\user"
}

Para remover WSL2

Configurações > Aplicativos e Recursos

  • Seleciona a distribuição Linux e remove
  • Seleciona Windows Subsystem for Linux Update

Windows + R + digitar "control"

Desmarcar as seguintes opções:

  • Windows Hipervisor Platform
  • Windows Subsystem for Linux
  • Hyper-V

Reinicie a máquina.

Executar aplicativos de GUI do Linux

# instala o gedit
sudo apt install gedit -y

# executa o gedit
gedit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment