如何管理Linux(WSL)发行版Windows子系统
使用wsl -l -v列出已安装的发行版及其状态;2. 用wsl --set-default设置默认发行版,wsl --set-version切换WSL版本;3. 通过wsl --install -d安装新发行版;4. 使用wsl --unregister卸载发行版并删除所有数据;5. 用wsl -d启动、wsl --terminate停止特定发行版,wsl --shutdown关闭所有实例;6. 使用wsl --export导出和wsl --import导入发行版以实现备份或迁移;7. 通过配置/etc/wsl.conf设置默认用户;8. 运行wsl --update更新内核,必要时回滚或调整自动更新设置,建议始终使用WSL 2并将发行版存储在SSD上以获得最佳性能。
Managing Windows Subsystem for Linux (WSL) distributions is straightforward once you know the right commands and tools. Whether you're installing, removing, switching between versions, or troubleshooting, here’s what you need to know.

1. List Installed WSL Distributions
To see which Linux distributions you’ve installed and their status:
wsl --list --verbose
or shorthand:

wsl -l -v
This shows:
- Distribution name
- WSL version (1 or 2)
- Current state (Running / Stopped)
2. Set Default Distribution and WSL Version
Set a default Linux distribution
When you run wsl
, it launches the default distro. To change it:

wsl --set-default <DistributionName>
Example:
wsl --set-default Ubuntu-22.04
Change WSL version for a distribution
You can switch between WSL 1 and WSL 2 (WSL 2 is recommended for better performance and full system call compatibility).
Check your current version:
wsl -l -v
Upgrade to WSL 2:
wsl --set-version <DistributionName> 2
Downgrade to WSL 1 (if needed):
wsl --set-version <DistributionName> 1
⚠️ Note: Downgrading may take time and isn't always recommended. WSL 2 is faster and more compatible.
3. Install a New Distribution
You can install Linux distros from the Microsoft Store (e.g., Ubuntu, Debian, Kali, Alpine), or manually via command line.
Install from command line:
wsl --install -d <DistributionName>
Example:
wsl --install -d Ubuntu
To see all available distributions:
wsl --list --online
Or:
wsl --show-distributions
4. Remove or Uninstall a Distribution
If you no longer need a Linux distribution:
wsl --unregister <DistributionName>
Example:
wsl --unregister Debian
This removes the distribution, all its files, settings, and user data. Be careful—this cannot be undone.
5. Start, Shut Down, or Terminate Distributions
Start a specific distribution:
wsl --distribution <DistributionName>
or:
wsl -d <DistributionName>
Shut down a running distribution:
wsl --terminate <DistributionName>
This stops the instance. It will restart cleanly next time.
Shut down all running distributions:
wsl --shutdown
Useful when troubleshooting network issues or file locks.
6. Import and Export Distributions (Backup & Migrate)
You can export a distribution to a tar file (great for backup), then import it later or on another machine.
Export a distribution:
wsl --export <DistributionName> <FileName>.tar
Example:
wsl --export Ubuntu backup-ubuntu.tar
Import a new distribution from a tar file:
wsl --import <NewName> <InstallPath> <BackupFile.tar> --version 2
Example:
wsl --import MyUbuntu D:\wsl\MyUbuntu backup-ubuntu.tar --version 2
Note: After import, the default user is root. To set a default user, you’ll need to configure
/etc/wsl.conf
or use a launcher app.
7. Set Default User in a Distribution
After importing or installing, you might end up as root. To set your regular user as default:
Launch the distro:
wsl -d <DistributionName>
Create or edit
/etc/wsl.conf
:[user] default = yourusername
Exit and terminate:
wsl --terminate <DistributionName>
Next time you start it, you’ll log in as that user.
8. Manage Kernel and Updates
Update WSL kernel: Run in PowerShell (as admin):
wsl --update
Rollback (if update causes issues):
wsl --update --rollback
Set update policy:
wsl --set-update-settings --auto-update Disabled
(or
Enabled
,Defer
)
Final Tips
- Always use WSL 2 unless you have a specific reason not to.
- Use
wsl --shutdown
before hibernating or troubleshooting. - Back up important distros using
--export
before unregistering. - Store distributions on an SSD for better performance.
Basically, with
wsl --list
,--set-default
,--unregister
, and--export/import
, you’ve got full control over your Linux environments on Windows.以上是如何管理Linux(WSL)发行版Windows子系统的详细内容。更多信息请关注PHP中文网其他相关文章!

热AI工具

Undress AI Tool
免费脱衣服图片

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Stock Market GPT
人工智能驱动投资研究,做出更明智的决策

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

爱思助手正版下载入口在官网https://www.i4.cn/,提供电脑端和手机端下载,支持设备管理、应用安装、模式切换、屏幕投射及文件管理等功能。

9月18日最新消息,华为HarmonyOS6已启动多轮面向开发者的预览版推送,近期更首次向部分尝鲜用户开放体验资格。根据用户反馈,当前系统名称已不再显示“NEXT”后缀,正式更名为HarmonyOS6.0。华为最初于2023年8月的开发者大会首次提出HarmonyOSNEXT这一命名,旨在标志鸿蒙系统迈入全新发展阶段,实现真正的原生自研。HarmonyOSNEXT最核心的突破在于彻底采用自主研发的系统底层架构,全面移除Linux内核及安卓AOSP代码,仅运行基于HarmonyOS内核的应用程序,

torunwindowsProgramsonLinux,TrytheSemethods:1。usesewinetodirectlyrun.exefiles.2.installplayonlinuxforeasierwinemanagement.3.setupawindowsvirtualmachinewithvirtualbox.4.uselututristointristristoinstallandrundrundrunwindrundrunwindrunwindrunwindrundrunwindremeseameameameameamemellysly。

tolocateaprogram'sinstallationPathOnlinux,使用:1。WHAICHPROGRAME_NAMEFORQUICKPATS基础lookup.2.Whereisprogram_nametofingrogram_nametofindbinaries,manpages.3.locateWithupDateWithupDatedBandGrepforfastFastFastFastFastFastFastFastFastFastilesearches.4.4.find/typef-typef-typef-typef-ecececutable-name-name progry'progry'progry'fort

UseGUItoolslikeStartupApplicationsinGNOME,AutostartinKDE,orSessionandStartupinXfcetomanageloginprograms.2.Manuallyaddstartupentriesvia.desktopfilesin~/.config/autostart/followingXDGstandards.3.Forsystem-levelservices,usesystemctlenable/disabletocontr

TotakesCreenshotsonLinux:1。useprtscnkeyforfullscreen,alt prtscnforactiveWindow.2.UseGnomesCreensHottoolShottoolFormoreOptions.3.UseGeSnome-ScreenshotCommandInterminal.4.InstallandSallandSallansCrotforlightweightlightweightweightlightweightweightlightweightlightweightCommand-command-command-lineCapturing。

toinstallvScodeonLinux,Usetheeficialaptrepositoryforautomationupdates,SnapforCross-Distribution-Compatibility,Oramanualtarballforfullcontrol.ChooseBashioneBasedonyourSasedonyourSasedonyoursyStemsteneds和Needs。

ToCheckDiskSpaceOnlinux,Usedf-HforanoverViewOfStorage,Du-ShtofIndDirectorySizes,lsblktolistblockdevices,OrinstallncduforanInteractiveanalysission.thesetoolsetoolshelpmonitor和manageSkusageSkusageSkusageSkusageageSageSkusageSageSkageAgefly。
