1. 打开Microsoft Store,搜索Ubuntu,并下载Ubuntu-18.04
2. 创建账号和密码,然后等待安装
3. 切换到root用户的两种方式
切换超级用户
sudo su
:命令行$之前
的信息会
变成白色
sudo -s
:命令行$之前
的信息不会
变成白色【家目录不会变】
4. 安装windows终端Windows Terminal Preview
5. 修改Windows Terminal Preview的配置
该配置中:
复制为:ctrl + shift + c
粘贴为:ctrl + shift + v
查找为:ctrl + shift + f
横向切分窗口:alt + shift + '+'
纵向切分窗口:alt + shift + '-'
关闭窗口(1):ctrl + d
关闭窗口(2):ctrl + shift + w
窗口统一输入为:ctrl + b
{
"$help": "https://aka.ms/terminal-documentation",
"$schema": "https://aka.ms/terminal-profiles-schema-preview",
"actions":
[
{
"command": "toggleBroadcastInput",
"id": "User.toggleBroadcastInput",
"keys": "ctrl+b"
},
{
"command":
{
"action": "copy",
"singleLine": false
},
"id": "User.copy.644BA8F2",
"keys": "ctrl+shift+c"
},
{
"command": "paste",
"id": "User.paste",
"keys": "ctrl+shift+v"
},
{
"command": "find",
"id": "User.find",
"keys": "ctrl+shift+f"
},
{
"command":
{
"action": "splitPane",
"split": "auto",
"splitMode": "duplicate"
},
"id": "User.splitPane.A6751878",
"keys": "alt+shift+d"
}
],
"copyFormatting": "none",
"copyOnSelect": false,
"defaultProfile": "{24a0533e-913b-5f8c-a5cb-6be85a4c9e70}",
"newTabMenu":
[
{
"type": "remainingProfiles"
}
],
"profiles":
{
"defaults": {},
"list":
[
{
"commandline": "%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"hidden": false,
"name": "Windows PowerShell"
},
{
"commandline": "%SystemRoot%\\System32\\cmd.exe",
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"hidden": false,
"name": "\u547d\u4ee4\u63d0\u793a\u7b26"
},
{
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
"hidden": false,
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure"
},
{
"guid": "{2ece5bfe-50ed-5f3a-ab87-5cd4baafed2b}",
"hidden": false,
"name": "Git Bash",
"source": "Git"
},
{
"guid": "{24a0533e-913b-5f8c-a5cb-6be85a4c9e70}",
"hidden": false,
"name": "Ubuntu-18.04",
"source": "CanonicalGroupLimited.Ubuntu18.04LTS_79rhkp1fndgsc"
}
]
},
"schemes": [],
"themes": []
}
6. 修改wsl的内存
windows系统中,在当前用户的家目录下,创建文件
.wslconfig
。内容如下:
[wsl2]
memory=2GB
swap=4GB
localhostForwarding=true
-
通过命令
free -mh
,查看内存是否已修改
-
官网示例,如下图: