Win10 Hyper-V 虚拟机使用体验(Ubuntu Server)

961 阅读2分钟

安装

打开Hyper-V管理器,可以看到最左侧是本地PC,中间是该PC下已有的虚拟机,点击右侧操作栏的快速创建可以新建虚拟机。 image.png

虚拟机可以使用.iso镜像或已有的虚拟机文件创建。 image.png

不是安装的window系统,不要勾选下面该选项

image.png

创建完成后,可以进配置,给虚拟机配置硬件参数:

image.png

设置静态IP

系统安装好后,默认是DHCP模式的,IP不是固定的,不方便SSH连接,建议修改为静态IP。 以Ubuntu 18.04为例:

  1. sudo vim /etc/netplan/**.yaml 并将文件内容修改为以下内容
     # This is the network config written by 'subiquity'
     # dhcp config
     # network:
     #  ethernets:
     #    eth0:
     #      dhcp4: true
     #  version: 2
    
     # staic ip
     network:
       version: 2
       ethernets:
         eth0:      
           addresses: [192.168.182.67/28]
           dhcp4: no
           dhcp6: no
           gateway4: 192.168.182.65   # 网关IP,通过查看网络管理虚拟网卡的属性可以看到
           nameservers:
             addresses: [192.168.182.65]  # DNS服务器
    
    即:将原来DHCP的网络个关掉, 使用静态IP

image.png

image.png

安装vim

一般系统默认自带的都是vim-tiny

查看安装的vim版本

zjl@zjl:~/mycode/vim-playground$ apt list --installed | grep vim

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

vim/bionic-updates,bionic-security,now 2:8.0.1453-1ubuntu1.4 amd64 [installed,automatic]
vim-common/bionic-updates,bionic-security,now 2:8.0.1453-1ubuntu1.4 all [installed,automatic]
vim-runtime/bionic-updates,bionic-security,now 2:8.0.1453-1ubuntu1.4 all [installed,automatic]
vim-tiny/bionic-updates,bionic-security,now 2:8.0.1453-1ubuntu1.4 amd64 [installed,automatic]
zjl@zjl:~/mycode/vim-playground$

vim version

zjl@zjl:~/mycode/vim-playground$ vim --version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Oct 13 2020 15:49:09)
Included patches: 1-1453
Modified by pkg-vim-maintainers@lists.alioth.debian.org
Compiled by pkg-vim-maintainers@lists.alioth.debian.org
Huge version without GUI.  Features included (+) or not (-):
+acl               +farsi             +mouse_sgr         -tag_any_white
+arabic            +file_in_path      -mouse_sysmouse    -tcl
+autocmd           +find_in_path      +mouse_urxvt       +termguicolors
-autoservername    +float             +mouse_xterm       +terminal
-balloon_eval      +folding           +multi_byte        +terminfo
+balloon_eval_term -footer            +multi_lang        +termresponse
-browse            +fork()            -mzscheme          +textobjects
++builtin_terms    +gettext           +netbeans_intg     +timers
+byte_offset       -hangul_input      +num64             +title
+channel           +iconv             +packages          -toolbar
+cindent           +insert_expand     +path_extra        +user_commands
-clientserver      +job               -perl              +vertsplit
-clipboard         +jumplist          +persistent_undo   +virtualedit
+cmdline_compl     +keymap            +postscript        +visual
+cmdline_hist      +lambda            +printer           +visualextra
+cmdline_info      +langmap           +profile           +viminfo
+comments          +libcall           -python            +vreplace
+conceal           +linebreak         +python3           +wildignore
+cryptv            +lispindent        +quickfix          +wildmenu
+cscope            +listcmds          +reltime           +windows
+cursorbind        +localmap          +rightleft         +writebackup
+cursorshape       -lua               -ruby              -X11
+dialog_con        +menu              +scrollbind        -xfontset
+diff              +mksession         +signs             -xim
+digraphs          +modify_fname      +smartindent       -xpm
-dnd               +mouse             +startuptime       -xsmp
-ebcdic            -mouseshape        +statusline        -xterm_clipboard
+emacs_tags        +mouse_dec         -sun_workshop      -xterm_save
+eval              +mouse_gpm         +syntax
+ex_extra          -mouse_jsbterm     +tag_binary
+extra_search      +mouse_netterm     +tag_old_static
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -Wdate-time  -g -O2 -fdebug-prefix-map=/build/vim-EfP9JP/vim-8.0.1453=. -fstack-protector-strong -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc   -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim        -lm -ltinfo -lnsl  -lselinux  -lacl -lattr -lgpm -ldl     -L/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu -lpython3.6m -lpthread -ldl -lutil -lm
zjl@zjl:~/mycode/vim-playground$ apt list --upgradable | grep vim

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

zjl@zjl:~/mycode/vim-playground$ 

有必要的话可以安装vim-nox(有较全功能的文本界面 Vim 包)。

zjl@zjl:~/mycode/vim-playground$ vim --version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Oct 13 2020 15:49:09)
Included patches: 1-1453
Modified by pkg-vim-maintainers@lists.alioth.debian.org
Compiled by pkg-vim-maintainers@lists.alioth.debian.org
Huge version without GUI.  Features included (+) or not (-):
+acl               +farsi             +mouse_sgr         -tag_any_white
+arabic            +file_in_path      -mouse_sysmouse    +tcl
+autocmd           +find_in_path      +mouse_urxvt       +termguicolors
-autoservername    +float             +mouse_xterm       +terminal
-balloon_eval      +folding           +multi_byte        +terminfo
+balloon_eval_term -footer            +multi_lang        +termresponse
-browse            +fork()            -mzscheme          +textobjects
++builtin_terms    +gettext           +netbeans_intg     +timers
+byte_offset       -hangul_input      +num64             +title
+channel           +iconv             +packages          -toolbar
+cindent           +insert_expand     +path_extra        +user_commands
-clientserver      +job               +perl              +vertsplit
-clipboard         +jumplist          +persistent_undo   +virtualedit
+cmdline_compl     +keymap            +postscript        +visual
+cmdline_hist      +lambda            +printer           +visualextra
+cmdline_info      +langmap           +profile           +viminfo
+comments          +libcall           -python            +vreplace
+conceal           +linebreak         +python3           +wildignore
+cryptv            +lispindent        +quickfix          +wildmenu
+cscope            +listcmds          +reltime           +windows
+cursorbind        +localmap          +rightleft         +writebackup
+cursorshape       +lua               +ruby              -X11
+dialog_con        +menu              +scrollbind        -xfontset
+diff              +mksession         +signs             -xim
+digraphs          +modify_fname      +smartindent       -xpm
-dnd               +mouse             +startuptime       -xsmp
-ebcdic            -mouseshape        +statusline        -xterm_clipboard
+emacs_tags        +mouse_dec         -sun_workshop      -xterm_save
+eval              +mouse_gpm         +syntax
+ex_extra          -mouse_jsbterm     +tag_binary
+extra_search      +mouse_netterm     +tag_old_static
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -Wdate-time  -g -O2 -fdebug-prefix-map=/build/vim-EfP9JP/vim-8.0.1453=. -fstack-protector-strong -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc   -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E  -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim        -lm -ltinfo -lnsl  -lselinux  -lacl -lattr -lgpm -ldl  -L/usr/lib -llua5.2 -Wl,-E  -fstack-protector-strong -L/usr/local/lib  -L/usr/lib/x86_64-linux-gnu/perl/5.26/CORE -lperl -ldl -lm -lpthread -lcrypt  -L/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu -lpython3.6m -lpthread -ldl -lutil -lm -L/usr/lib/x86_64-linux-gnu -ltcl8.6 -ldl -lz -lpthread -lm -lruby-2.5 -lpthread -lgmp -ldl -lcrypt -lm
zjl@zjl:~/mycode/vim-playground$

不过感觉也没多了啥,就多了 lua, perl

安装vim中文手册

cd ~/.vim
mkdir -p pack/my/start
git clone https://github.com/yianwillis/vimcdoc.git pack/my/start/vimcdoc

开启vim教程

$ LANG=zh_CN.UTF-8 vimtutor

设置代理

将如下内容写入 /etc/profile.d/proxy.sh 文件

 # set proxy config via profie.d - should apply for all users
export http_proxy="http://PROXY_IP:PORT"
export https_proxy="http://PROXY_IP:PORT"
export ftp_proxy="http://PROXY_IP:PORT"
export no_proxy="127.0.0.1,localhost" #将要从代理中排除的其他IP添加到NO_PROXY和no_proxy环境变量中
# For curl
export HTTP_PROXY="http://PROXY_IP:PORT"
export HTTPS_PROXY="http://PROXY_IP:PORT"
export FTP_PROXY="http://PROXY_IP:PORT"
export NO_PROXY="127.0.0.1,localhost" #将要从代理中排除的其他IP添加到NO_PROXY和no_proxy环境变量中

需要开启代理时执行如下脚本即可:

$ sudo chmod +x proxy.sh
$ source /etc/profile.d/proxy.sh

image.png