WSL distros can now run Linux commands on startup in Windows 10

Windows keys

Windows Insiders who install the latest build of Windows 10 are being treated to a powerful new option in WSL (Windows Subsystem for Linux) -- the ability to run Linux commands when a distro starts up.

The new feature can be used to run things such as environment configuration scripts and more. This is an extremely versatile option that will be welcomed by power users, as well as anyone interested in taking their usage of Windows Subsystem for Linux to the next level.

See also:

Introducing the new functionality in a blog post about the latest build of Windows 10, Microsoft's Brandon LeBlanc says: "We have added an option that allows you to run any specified Linux command on startup of a WSL distribution. You can accomplish this by editing the /etc/wsl.conf file in your distribution and adding an option titled "command" under a section titled "boot". This command will run whenever your specific WSL distribution starts up. The example below shows using this functionality to create a method to log the time and date for each startup of this WSL distro".

He goes on to explain:

This command will run when a WSL distribution is first started. WSL distributions will remain running for a few minutes even after the last Linux process inside of them is closed. You can view if your WSL distro is running using wsl --list --verbose and you can manually shut down all WSL distributions using wsl --shutdown.

To take advantage of this new feature of WSL, you need to be running Windows 10 Build 21286.

Image credit: tomeqs / Shutterstock

4 Responses to WSL distros can now run Linux commands on startup in Windows 10

© 1998-2024 BetaNews, Inc. All Rights Reserved. Privacy Policy - Cookie Policy.