分类
公众号「0加1」

Windows10安装Ubuntu20.04虚拟机折腾全纪录(持续更新中)


title: Windows10安装Ubuntu20.04虚拟机折腾全纪录(持续更新中)

最近做开发,收到一个只能在Linux运行的二进制文件,于是在本地开启了Linux虚拟机运行二进制程序。

通过虚拟机的文件夹共享功能,我可以在Windows写代码,在Linux实时运行程序。

image-20201201231341669

整套折腾下来,我对Mac的依赖降低了,以后没有Mac, 我也可以用Windows运行Linux做开发,而不用去和Windows各种玄学的环境变量配置去对线。

为虚拟机Linux安装开发环境还有一个好处,你可以把配置好的Linux开发环境放到任何一台PC或Mac或Linux主机上运行,换新电脑也不用重装环境~

折腾之路上,我遇到很多坑,这里记录一下,漂移过弯的最佳路径。

环境配置

  • 主机环境: Windows10 32GB内存(其实8GB也够用)

  • 虚拟机软件 Vmware WorkStation 16 下载地址 https://zhaooolee.cowtransfer.com/s/46acd06559f04b 激活码 ZF3R0-FHED2-M80TY-8QYGC-NPKYF

  • 虚拟机镜像 Ubuntu 20.04 下载地址 https://zhaooolee.cowtransfer.com/s/525fe6c45a2743

image-20201201224150700

虚拟机安装Linux镜像的小经验

  • 默认选择英语安装,这样bash路径都会保持英文(当然你可以在安装完成后,再切换到中文)
  • 给虚拟机分配4GB内存,开发够用了!
  • 给Ubuntu做美化挺费时间的,如果喜欢高颜值,可以直接选择Deepin

更换阿里源

# 备份源
sudo cp /etc/apt/sources.list  /etc/apt/sources.list_backup
# 编辑源
sudo vi /etc/apt/sources.list

将sources.list内的内容替换为以下阿里源

deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

更新源

sudo apt update

安装vim

sudo apt install vim -y

安装git

sudo apt install git -y

安装zsh, 用zsh替换默认的终端bash

sudo apt install zsh -y

安装curl (为下一步下载oh-my-zsh做准备)

sudo apt install curl -y

安装oh-my-zsh (这里我使用了gitee镜像源), oh-my-zsh让zsh更好用

sh -c "$(curl -fsSL https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh)"

安装nvm (这里我使用了gitee镜像源), 管理Node.js

curl -o- https://gitee.com/mirrors/nvm/raw/master/install.sh | bash

使用NVM安装Node.js 14

nvm install 14.0.0

设置Node.js 14 为默认Node.js版本

# 开始使用Node.js 14
nvm use 14.0.0
# 设置默认Node.js版本为14
nvm alias default 14.0.0
# 查看Node.js版本
node -v

image-20201202093354699

安装npm (不可缺少的依赖包管理工具)

sudo apt install npm -y

如果 npm install 出现错误,则运行以下命令

# INSTALL GLOBAL NPM PACKAGES
npm config set unsafe-perm true

# CLEAN CACHE (有时候这一步会报错,忽略即可)
npm cache clean

# BYPASS SYMLINK ISSUES
npm install --no-bin-links

前端常用命令行工具

# 通过命令行简单开启http-server服务
npm install -g http-server
# 可以监控文件变化,自动重启Node.js服务的命令行工具
npm install -g nodemon
# 守护多个后台程序的工具PM2
npm install -g pm2

我们试用snap替代apt安装应用软件

snap可以同时运行多个安装命令,比如在终端窗口1 运行sudo snap install postman 的同时,在终端窗口2 运行 sudo snap install chromium

安装Postman (api测试工具)

image-20201202101011147

sudo snap install postman

安装Chrome 开发者版本 (开源版Chrome浏览器)

image-20201202101002134

sudo snap install chromium

安装网易云音乐 (Linux最好的音乐软件/ 设计超棒的音乐软件)

image-20201202100944045

image-20201202112451783

sudo snap install netease-music --devmode --beta

安装WebStorm (大前端开发)

image-20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%E6%B4%BB

安装VsCode (蓝星最强编辑器)

image-20201202101130450

sudo snap install vscode --classic

安装Typora (写Markdown必备)

image-20201202102309890

sudo snap install typora --classic

安装官方QQ Linux (deb安装包安装)

image-20201202112031712

wget http://down.qq.com/qqweb/LinuxQQ/linuxqq_2.0.0-b2-1084_amd64.deb
sudo dpkg -i linuxqq_2.0.0-b2-1084_amd64.deb

ToDesk远程控制

sudo wget https://update.todesk.com/todeskBeta_1.1.0c.deb
sudo dpkg -i todeskBeta_1.1.0c.deb

image-20201202122320213

命令行「逼装」软件

安装glances (查看系统运行状态)

sudo apt install glances -y

image-20201202122936944

# 运行
glances
# 退出
q

黑客帝国动态字符雨

sudo apt-get install cmatrix -y

image-20201202113042822

# 运行
cmatrix
# 退出
q

命令行查看本城市天气预报

image-20201202123618620

# 以深圳为例
http://wttr.in/shenzhen

在终端打开当前路径窗口

xdg-open ./

2020-12-03-xdg-open

小技巧: 如果感觉xdg-open 很长,我们可以配置alias, 然后使用open代替xdg-open

alias open=xdg-open

2020-12-03-zsh-open

为Python3安装pip3(为后面安装Python各种小工具做基础)

Ubuntu20.04已经原生携带Python3 ,为了使用更多Python命令行工具,我们需要安装Python包管理工具pip3

# 安装pip3
sudo apt install python3-pip -y
# 查看pip3 版本
pip3 --version

image-20201203101550636

安装网站视频神器 you-get

# 安装you-get
pip3 install you-get
# 升级you-get
pip3 install --upgrade you-get

image-20201203103305854

将you-get安装路径/home/zhaoolee/.local/bin添加到~/.zshrc (/home/zhaoolee/.local/bin可以表示为$HOME/.local/bin )

image-20201203103820935

# 让新PATH生效
source ~/.zshrc
# you-get下载B站视频
you-get https://www.bilibili.com/video/BV1nt4y1S7ti/

image-20201203104120532

安装网易云音乐命令行版

开源地址

https://github.com/darknessomi/musicbox

安装

 pip3 install NetEase-MusicBox

启动

musicbox

2020-12-03-music-box

操作方法
j下移
k上移
回车确定
h后退
q退出

终端查看Linux发行版命令行工具

sudo apt install neofetch -y

image-20201203111705305

# 运行
neofetch

安装Docker

#使用 apt-get 进行安装
# step 1: 安装必要的一些系统工具
sudo apt update
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
# step 2: 安装GPG证书
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
# Step 3: 写入软件源信息
sudo add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
# Step 4: 更新并安装Docker-CE
sudo apt-get -y update
sudo apt-get -y install docker-ce
# Step 5: 查看Docker版本
docker -v

image-20201203112527859

运行基于Docker的命令行小游戏《贪吃蛇》

sudo docker run -ti dyego/snake-game

2020-12-03-sna

一个没啥用的工具--字符《小火车》

# 安装小火车
sudo apt install sl
# 运行小火车
sl

如果你将ls打错为sl,这个小火车便会出现在你的命令行。

2020-12-03-sl

清理系统无用的依赖包

sudo apt autoremove

小结

整体体验下来, Ubuntu20.04部署开发环境还是蛮顺滑的;

有些应用软件的支持并不完美, 比如微软的Edge浏览器开发版就出现了白屏的现象, 不过有FireFox和Chrome开发版,上网冲浪和开发也完全够用了。

阅读原文(支持读写评论)

https://www.v2fy.com/p/2020-12-02-ubuntu20-dev/

发表评论

电子邮件地址不会被公开。 必填项已用*标注


The maximum upload file size: 2 MB.
You can upload: image, audio, video, document, spreadsheet, interactive, text, archive, code, other.
Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded.