WSL安装以及配置.md 3.2 KB


notion-id: 8866ccd3-815f-49a7-85a5-49bf52e8d7

❤️Wsl终端优化配置❤️ Wsl桌面环境

[!note]+ 输入法安装问题 注意:fcitx-config-gtk3 没有出现输入法,可用fcitx-autostart 刷新一下,再执行。 注意:~/.profile 是root权限下的文件,非home,可参考下面文件

# ~/.profile: executed by Bourne-compatible login shells.

if [ "$BASH" ]; then
  if [ -f ~/.bashrc ]; then
    . ~/.bashrc
  fi
fi

mesg n 2> /dev/null || true

export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS=@im=fcitx
export DefaultIMModule=fcitx
fcitx-autostart &>/dev/null

注意:安装完毕以后,重启系统 然后windows终端重新进入然后需要root权限,参考一下操作

wsl —shutdown
sudo -i
fcitx-config-gtk3 查看输入法是否已经显示
然后使用gedit测试输入法是否可以正常使用

wsl --unregister 发行版名称 可移除指定的发行版 关闭指定的单个发行版:wsl -t 发行版名称 关闭所有正在运行的发行版:wsl --shutdown lsb_release -a 查看内核核心 cmd 输入\\wsl$ 网络映射添加网络位置,直接访问文件

Wsl配置Ubuntu,可参照

https://zhuanlan.zhihu.com/p/430031921 https://www.jianshu.com/p/a20c2d58eaac

[!note]+ # Wsl固定IP地址Bat

@echo off
::变量延迟
setlocal enabledelayedexpansion

::停止所有可能在跑的wsl实例
::wsl --shutdown ubuntu
::以下指令关闭所有实例
wsl --shutdown
::重新拉起来,并且用root的身份,启动ssh服务和docker服务
wsl -u root service ssh start
::wsl -u root service docker start | findstr "Starting Docker" > nul
if !errorlevel! equ 0 (
    ::echo docker start success
:: 看看我要的IP在不在
    wsl -u root ip addr | findstr "192.168.120.181" > nul
    if !errorlevel! equ 0 (
        echo wsl ip has set
    ) else (
::不在的话给安排上
        wsl -u root ip addr add 192.168.120.10/24 broadcast 192.168.120.0 dev eth0 label eth0:1
        echo set wsl ip success: 192.168.120.10
    )


::windows作为wsl的宿主,在wsl的固定IP的同一网段也给安排另外一个IP
    ipconfig | findstr "192.168.120.100" > nul
    if !errorlevel! equ 0 (
        echo windows ip has set
    ) else (
        netsh interface ip add address "vEthernet (WSL)" 192.168.120.100 255.255.255.0
        echo set windows ip success: 192.168.120.100
    )
)
pause

[!note]+ # Wsl源配置问题 https://blog.csdn.net/weixin_41529012/article/details/117226884 https://blog.csdn.net/laichilizi/article/details/125776317 sudo cp /etc/apt/trusted.gpg /etc/apt/trusted.gpg.d 更新报错