Win10 Bash更改默认用户

本文介绍如何在Windows 10系统中使用Ubuntu的Bash环境,并提供了详细的命令说明,包括更改默认登录用户、安装、卸载及更新Bash的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Win10已经支持Ubuntu的Bash了。

在cmd中输入bash就可以进入bash界面。但此时是普通用户登录的。

如果希望更改默认的登录用户,可以在cmd中更改。

具体的命令是:

lxrun /setdefaultuser root
Found UNIX user: root
Default UNIX user set to: root

lxrun是管理bash on win10的工具。可以install、uninstall或update。

lxrun的help信息:

lxrun -h
Performs administrative operations on the LX subsystem

Usage:
    /install - Installs the subsystem
        Optional arguments:
            /y - Do not prompt user to accept
    /uninstall - Uninstalls the subsystem
        Optional arguments:
            /full - Perform a full uninstall
            /y - Do not prompt user to accept
    /setdefaultuser - Configures the subsystem user that bash will be launched as. If the user does not exist it will be created.
        Optional arguments:
            username - Supply the username
            /y - If username is supplied, do not prompt to create a password
    /update - Updates the subsystem's package index

比如安装Bash:

lxrun /install
-- Beta feature --
This will install Ubuntu on Windows, distributed by Canonical
and licensed under its terms available here:
https://aka.ms/uowterms
Type "y" to continue: y
Downloading from the Windows Store... 100%
Extracting filesystem, this will take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: hengwei
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Installation successful!

比如删除Bash:

lxrun /uninstall
This will uninstall Ubuntu on Windows.
This will remove the Ubuntu environment as well as any modifications and new applications with the exception of:

C:\Users\hengwei\AppData\Local\lxss\home
C:\Users\hengwei\AppData\Local\lxss\root

Type "y" to continue: y
Uninstalling...

比如更新Bash:

lxrun /update
Checking for updates...
Ign http://archive.ubuntu.com trusty InRelease
Get:1 http://security.ubuntu.com trusty-security InRelease [65.9 kB]
Get:2 http://archive.ubuntu.com trusty-updates InRelease [65.9 kB]
Get:3 http://security.ubuntu.com trusty-security/main amd64 Packages [606 kB]
Hit http://archive.ubuntu.com trusty-backports InRelease
......

 

转载于:https://www.cnblogs.com/hengwei/p/6702732.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值