How to run Linux commands when starting Windows Subsystem for Linux on Windows 10

The latest beta version of Windows 10 allows users to automatically run Linux commands when Windows Subsystem for Linux starts.

Microsoft has just added a new feature for Windows Subsystem for Linux (WSL) on Windows 10. Specifically, WSL users on the latest beta version of Windows can set up Linux commands to automatically run when WSL starts. .

WSL is a compatibility layer designed by Microsoft to help Windows 10 run Linux binaries in native ELF format on Windows computers. In other words, users can run Linux commands right on Windows 10 without having to parallel install and switch between Linux and Windows.

How to run Linux commands when starting Windows Subsystem for Linux on Windows 10

Condition:

  1. Update the latest Windows 10 beta, Build 21286
  2. Install WSL

Doing:

  1. Edit /etc/wsl.conf and add an option titled command below the section titled boot
  2. Once added to the /etc/wsl.conf file , Linux commands will automatically run when the WSL distributions are started.
  3. WSL distributions will still run for a few minutes even after the Linux process inside them is closed
  4. You can check the distributions that are running using the command wsl --list --verboseand manually turn off all WSL distributions with the command.wsl --shutdown

How to run Linux commands when starting Windows Subsystem for Linux on Windows 10 Picture 1How to run Linux commands when starting Windows Subsystem for Linux on Windows 10 Picture 1

If the testing goes well, this feature will soon be released by Microsoft in Windows 10 official release. Expected in 2021, Microsoft will have many updates and upgrades worthwhile for Windows 10 in terms of both interface and features.

Good luck.

4.4 ★ | 5 Vote