Coder Social home page Coder Social logo

Comments (3)

kousu avatar kousu commented on June 15, 2024

Ah, I read the docs: there's

wsl -u root

which partially helps. If, say, you generalized --root to --user which worked so that, given --user someone, DistroLauncher runs useradd -m someone instead of using adduser then it won't prompt, and I can later use wsl -u root passwd someone to set the password, or echo 'someone:pass' | wsl -u root chpasswd to set it noninteractively.

from wsl-distrolauncher.

kousu avatar kousu commented on June 15, 2024

..and now I just noticed ubuntu1804 config --default-user username. Which pretty much covers everything I want.

DistroLauncher could make this smoother maybe with more obvious flags, but this works fine:

<distro>.exe install --root

wsl -u root -d <distro> useradd -m "$username"
wsl -u root -d <distro> sh -c "echo "${username}:${password}" | chpasswd"
wsl -u root -d <distro> chsh -s /bin/bash "$username"
wsl -u root -d <distro> usermod -aG adm,cdrom,sudo,dip,plugdev "$username"

<distro>.exe config --default-user "$username"

from wsl-distrolauncher.

kousu avatar kousu commented on June 15, 2024

Or, this is even better:

Given that you've grabbted the .appx link for a distro:

$distro = "ubuntu1804"
$distro_link = "https://aka.ms/wsl-ubuntu-1804"

$username = "ubuntu"
$password = "ubuntu"

Invoke-WebRequest -Uri $distro_link -OutFile ~/${distro}.appx -UseBasicParsing
Add-AppxPackage -Path ~/${distro}.appx


& $distro install --root

& $distro run useradd -m "$username"
& $distro run sh -c "echo "${username}:${password}" | chpasswd"
& $distro run chsh -s /bin/bash "$username"
& $distro run usermod -aG adm,cdrom,sudo,dip,plugdev "$username"

& $distro config --default-user "$username"

from wsl-distrolauncher.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.