发布时间: 2022-04-22 22:50:00
refer to: https://allthings.how/how-to-use-linux-terminal-in-windows-10/
1.1 需要你的设备是win10
1.2 需要开启 wsl
1.3 需要设置默认的wsl version
wsl --set-default-version 2 (管理员权限)
参考: https://jingyan.baidu.com/article/4ae03de3b59d223eff9e6b39.html
2.1 以管理员身份运行powser shell, 然后: Get-AppxPackage -allusers | Select Name, PackageFullName
2.2 ctrl + f 搜索 Microsoft.WindowsStore , 找到右侧的值
2.3 power shell 中,运行下面命令(记得根据上面的值做个替换)
Add-appxpackage -register "C:\Program Files\WindowsApps\Microsoft.WindowsStore_11811.1001.18.0_x64__8wekyb3d8bbwe\appxmanifest.xml"-disabledevelopmentmode
4. 运行它。
首次运行时,会看到弹窗,让我们设置用户:
现在你的windows中就有个ubuntu server了。
sudo nano /etc/resolv.conf
refer to: https://stackoverflow.com/questions/62314789/no-internet-connection-on-wsl-ubuntu-windows-subsystem-for-linux
nameserver 8.8.8.8
修改apt source , update !
修改 .bashrc
前提是需要在windows中安装好 git bash, 这样在wsl中才能有git.exe
这个问题是由于git 的原因造成的,具体见:https://github.com/microsoft/WSL/issues/4401
这个大哥说的非常好哈哈。
解决办法: 在.bashrc中加入这个。
function isWinDir { case $PWD/ in /mnt/*) return $(true);; *) return $(false);; esac } # wrap the git command to either run windows git or linux function git { if isWinDir then git.exe "$@" else /usr/bin/git "$@" fi }
https://stackoverflow.com/questions/5834014/lf-will-be-replaced-by-crlf-in-git-what-is-that-and-is-it-important
修改git config: ~/.gitconfig [core] repositoryformatversion = 0 filemode = false bare = false logallrefupdates = true autocrlf = true 下面是完整的内容(注意我用了socks5 proxy) [user] name = siwei email = [email protected] [core] repositoryformatversion = 0 filemode = false bare = false logallrefupdates = true autocrlf = true editor = vim [push] default = matching [http "https://github.com"] proxy = socks5h://192.168.10.50:1090 [https "https://github.com"] proxy = socks5h://192.168.10.50:1090
我也不知道它为啥叫这个名字。
安装: 在store中搜索 这个名字就可以看到了,也可以在github上找到直接安装。
或者直接下载 github上有。
运行,非常简单。
power shell 的打开, 这里需要用到docker, 所以就 ctrl + shift + g
linux: ctrl + shift + t
配置打开后的行为:
默认路径,
是否开机启动
(待定: 确定分词的能力)
win -> notepad -> 右键 -》 管理员打开 -> ctrl +o ->
在host机器上: ipconfig
在docker 机器上: ifconfig , ping, curl , telnet , 不要省那么点空间, 果断给docker 安装vim, git, ping 等命令。
其他的都不好使。172.17.0.1 啥的,在windows docker上不行。我也不知道为什么。
wsl --set-version Ubuntu-20.04 2 (这一句有用)
如下图所示
Back