文章目录
基础配置
更新
创建完 ubuntu 后,要先更新,千万不要先换源!
sudo apt update
sudo apt upgrade
设置 sudo 不用密码
我这里因为懒得每次 sudo 都输入密码,所以设置了不用密码,建议不选!
sudo visudo
# 在末尾添加以下配置
[username] ALL=(ALL) NOPASSWD: ALL
其中的 [username]
填你自己的用户名。
命令行美化
这里选择了最为常用的 zsh
+ oh-my-zsh
系列。
进行下面操作前,需要先安装 git。
安装 zsh
# 查看当前 shell
echo $SHELL # /bin/bash
# 查看系统自带的 shells
cat /etc/shells
# 如果没有 zsh 的话进行安装,建议开启代理再进行
sudo apt install zsh -y
# 再次查看系统的 shells,会出现 zsh
cat /etc/shells
# 设置 zsh 为默认 shell
chsh -s /bin/zsh
# 安装 oh-my-zsh,要有代理(二选一即可)
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
# 插件安装
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
# 在 ~/.zshrc 里启用
vim ~/.zshrc
# 找到 plugins=(git),添加
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
# 激活 ~/.zshrc
source ~/.zshrc
软件安装
Gedit
Gedit 是 Gnome 的默认文本编辑器。
我是因为在安装 ROS 是需要按照行数修改文件,才选择安装它。
sudo apt install gedit -y
Nautilus
Nautilus 也称为 GNOME Files,是 GNOME 桌面的文件管理器。( 类似于 Windows 文件资源管理器 )。
sudo apt install nautilus -y
# 启动 nautilus
nautilus
git
sudo apt install git -y
VSCode
搭配 Remote - WSL
插件,会非常好用。
# 会自动安装 VSCode
code .
Golang
1. 可选择 apt 安装
这样安装的版本好像只有 1.13.2,有点老。
sudo apt install golang
2. 下载 Go 压缩包
从官网下载最新版本的 Go,也可以自行去官方手动下载。
wget -c https://dl.google.com/go/go1.18.2.linux-amd64.tar.gz -O - | sudo tar -xz -C /usr/local
添加环境变量:
vim ~/.zshrc
export PATH=$PATH:/usr/local/go/bin
source ~/.zshrc
测试是否安装了 Go:
go version
配置 Go 的代理:
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.io,direct
配置完成后可以使用 go env
查看是否成功。
Nodejs
参照官网,通过使用 nvm
来安装 nodejs
。
# 要开启代理
proxy
# 安装 nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
目前这是最新版本的
nvm
,可以去查看是否是最新版本。
安装完成后,需要重启终端。
# 这里选择安装稳定的 LTS 版本的 nodejs
nvm install --lts
安装图形化界面
Gnome
gnome 是依赖与 systemd 的,而 wsl 2 默认不是以 systemd 作为初始化进程的,直接输入命令 systemtcl
会报错。
安装 systemd
# 建议
cd ~
git clone https://github.com/DamionGans/ubuntu-wsl2-systemd-script.git
cd ubuntu-wsl2-systemd-script/
bash ubuntu-wsl2-systemd-script.sh
然后重启 ubuntu 系统,输入 systemtcl
,就能正常运行了。
安装 Gnome
sudo apt install ubuntu-desktop
设置启动配置
sudo nano ~/.bashrc
# 在文章末尾添加以下配置
export DISPLAY=$(grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}'):0.0
export XDG_SESSION_TYPE=x11
# 然后保存、推出
source ~/.bashrc
启动桌面
打开 Xlaunch,输入 gonme-session
,就可以看到 Gonme 界面了!
不过会有点卡,也可以选择安装 Xfce4。