VMware 安装Ubuntu22.04

0、前提条件

操作系统:Windows10

VMware Workstation版本:15.1.0 build-13591040

1、安装

下载地址:下载Ubuntu桌面系统 | Ubuntu

打开VMware,选择文件 -> 新建虚拟机

配置类型选择典型,单击“下一步”按钮

选择“稍后安装操作系统”, 单击“下一步” 

选择Linux操作系统 ,版本选择Ubuntu 64位,单击“下一步”

填写虚拟机名称(也可以使用默认名称), 选择要安装的位置,单击“下一步”

设置磁盘大小,单击“下一步”

单击“自定义硬件”按钮

 

单击“内存”,设置虚拟机内存大小

单击“处理器”,选择处理器数量

选择“新CD/DVD(SATA)”, 连接选择“使用ISO映像文件”,选择ISO文件所在的路径

选择“网络适配器”, 网络连接选择“NAT模式” (下图第2步选择NAT模式)

单击“完成”按钮

单击“开启虚拟机”

 选择语言,点击“Install Ubuntu” button

单击“Continue”

 

单击“Continue”

 单击“Install Now”

 

鼠标点击地图中的中国区域,文本框自动显示为Shanghai,单击“Continue”

 

 设置用户名密码,单击“Continue”

安装需要几分钟时间,安装完后,单击“Restart Now”

2、配置

2.1 显示大小

点击左下角“Show Applications”, 右侧选择“Settings”

选择“Dispalys”,在“Resolution”下拉列表选择对应的分辨率,单击“Apply”按钮

2.2、虚拟机与主机复制粘贴

 打开一个终端

在终端输入如下命令: 

sudo apt-get install open-vm-tools-desktop

重启虚拟机,在终端输入如下命令:

reboot

2.3、以root管理员身份操作

设置root管理员密码

sudo passwd

tracy@tracy-virtual-machine:~$ sudo passwd
[sudo] password for tracy: 
New password: 
Retype new password: 
passwd: password updated successfully

切换root管理员用户 

su root 

tracy@tracy-virtual-machine:~$ su root
root@tracy-virtual-machine:/home/tracy# 

2.4、安装

2.4.1、vim

apt install vim

root@tracy-virtual-machine:/etc/netplan# apt install vim
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following package was automatically installed and is no longer required:
  systemd-hwe-hwdb
Use 'apt autoremove' to remove it.
The following additional packages will be installed:
  vim-common vim-runtime vim-tiny
Suggested packages:
  ctags vim-doc vim-scripts indent
The following NEW packages will be installed:
  vim vim-runtime
The following packages will be upgraded:
  vim-common vim-tiny
2 upgraded, 2 newly installed, 0 to remove and 187 not upgraded.
Need to get 8,560 kB/9,345 kB of archives.
After this operation, 37.6 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://cn.archive.ubuntu.com/ubuntu jammy-updates/main amd64 vim-runtime all 2:8.2.3995-1ubuntu2.1 [6,832 kB]
Get:2 http://cn.archive.ubuntu.com/ubuntu jammy-updates/main amd64 vim amd64 2:8.2.3995-1ubuntu2.1 [1,727 kB]
Fetched 8,560 kB in 27s (316 kB/s)                                             
(Reading database ... 195626 files and directories currently installed.)
Preparing to unpack .../vim-tiny_2%3a8.2.3995-1ubuntu2.1_amd64.deb ...
Unpacking vim-tiny (2:8.2.3995-1ubuntu2.1) over (2:8.2.3995-1ubuntu2) ...
Preparing to unpack .../vim-common_2%3a8.2.3995-1ubuntu2.1_all.deb ...
Unpacking vim-common (2:8.2.3995-1ubuntu2.1) over (2:8.2.3995-1ubuntu2) ...
Selecting previously unselected package vim-runtime.
Preparing to unpack .../vim-runtime_2%3a8.2.3995-1ubuntu2.1_all.deb ...
Adding 'diversion of /usr/share/vim/vim82/doc/help.txt to /usr/share/vim/vim82/d
oc/help.txt.vim-tiny by vim-runtime'
Adding 'diversion of /usr/share/vim/vim82/doc/tags to /usr/share/vim/vim82/doc/t
ags.vim-tiny by vim-runtime'
Unpacking vim-runtime (2:8.2.3995-1ubuntu2.1) ...
Selecting previously unselected package vim.
Preparing to unpack .../vim_2%3a8.2.3995-1ubuntu2.1_amd64.deb ...
Unpacking vim (2:8.2.3995-1ubuntu2.1) ...
Setting up vim-common (2:8.2.3995-1ubuntu2.1) ...
Setting up vim-runtime (2:8.2.3995-1ubuntu2.1) ...
Setting up vim (2:8.2.3995-1ubuntu2.1) ...
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vim (vim) in a
uto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vimdiff (vimdi
ff) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rvim (rvim) in
 auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rview (rview) 
in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vi (vi) in aut
o mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/view (view) in
 auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/ex (ex) in aut
o mode
Setting up vim-tiny (2:8.2.3995-1ubuntu2.1) ...
Processing triggers for mailcap (3.70+nmu1ubuntu1) ...
Processing triggers for desktop-file-utils (0.26-1ubuntu3) ...
Processing triggers for hicolor-icon-theme (0.17-2) ...
Processing triggers for gnome-menus (3.36.0-1ubuntu3) ...
Processing triggers for man-db (2.10.2-1) ...

 2.4.2、net-tools

如果在终端查看ifconfig出现如下信息:

ifconfig

root@tracy-virtual-machine:# ifconfig
Command 'ifconfig' not found, but can be installed with:
apt install net-tools

安装net-tools 

apt install net-tools

root@tracy-virtual-machine:# apt install net-tools
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following package was automatically installed and is no longer required:
  systemd-hwe-hwdb
Use 'apt autoremove' to remove it.
The following NEW packages will be installed:
  net-tools
0 upgraded, 1 newly installed, 0 to remove and 189 not upgraded.
Need to get 204 kB of archives.
After this operation, 819 kB of additional disk space will be used.
Get:1 http://cn.archive.ubuntu.com/ubuntu jammy/main amd64 net-tools amd64 1.60+git20181103.0eebece-1ubuntu5 [204 kB]
Fetched 204 kB in 2s (126 kB/s)     
Selecting previously unselected package net-tools.
(Reading database ... 195577 files and directories currently installed.)
Preparing to unpack .../net-tools_1.60+git20181103.0eebece-1ubuntu5_amd64.deb ..
.
Unpacking net-tools (1.60+git20181103.0eebece-1ubuntu5) ...
Setting up net-tools (1.60+git20181103.0eebece-1ubuntu5) ...
Processing triggers for man-db (2.10.2-1) ...

查看ifconfig

root@tracy-virtual-machine:# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.237.146  netmask 255.255.255.0  broadcast 192.168.237.255
        inet6 fe80::21c5:4983:13eb:6ddf  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:83:19:3d  txqueuelen 1000  (Ethernet)
        RX packets 1487  bytes 1327857 (1.3 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 756  bytes 58888 (58.8 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 132  bytes 11539 (11.5 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 132  bytes 11539 (11.5 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

2.4.3、openssh-server

sudo apt install openssh-server

root@tracy-virtual-machine:~$ sudo apt install openssh-server
[sudo] password for tracy: 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following package was automatically installed and is no longer required:
  systemd-hwe-hwdb
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
  ncurses-term openssh-sftp-server ssh-import-id
Suggested packages:
  molly-guard monkeysphere ssh-askpass
The following NEW packages will be installed:
  ncurses-term openssh-server openssh-sftp-server ssh-import-id
0 upgraded, 4 newly installed, 0 to remove and 187 not upgraded.
Need to get 751 kB of archives.
After this operation, 6,046 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://cn.archive.ubuntu.com/ubuntu jammy/main amd64 openssh-sftp-server amd64 1:8.9p1-3 [38.8 kB]
Get:2 http://cn.archive.ubuntu.com/ubuntu jammy/main amd64 openssh-server amd64 1:8.9p1-3 [434 kB]
Get:3 http://cn.archive.ubuntu.com/ubuntu jammy/main amd64 ncurses-term all 6.3-2 [267 kB]
Get:4 http://cn.archive.ubuntu.com/ubuntu jammy/main amd64 ssh-import-id all 5.11-0ubuntu1 [10.1 kB]
Fetched 751 kB in 5s (166 kB/s)        
Preconfiguring packages ...
Selecting previously unselected package openssh-sftp-server.
(Reading database ... 197567 files and directories currently installed.)
Preparing to unpack .../openssh-sftp-server_1%3a8.9p1-3_amd64.deb ...
Unpacking openssh-sftp-server (1:8.9p1-3) ...
Selecting previously unselected package openssh-server.
Preparing to unpack .../openssh-server_1%3a8.9p1-3_amd64.deb ...
Unpacking openssh-server (1:8.9p1-3) ...
Selecting previously unselected package ncurses-term.
Preparing to unpack .../ncurses-term_6.3-2_all.deb ...
Unpacking ncurses-term (6.3-2) ...
Selecting previously unselected package ssh-import-id.
Preparing to unpack .../ssh-import-id_5.11-0ubuntu1_all.deb ...
Unpacking ssh-import-id (5.11-0ubuntu1) ...
Setting up openssh-sftp-server (1:8.9p1-3) ...
Setting up openssh-server (1:8.9p1-3) ...

Creating config file /etc/ssh/sshd_config with new version
Creating SSH2 RSA key; this may take some time ...
3072 SHA256:QLlC3ZcCw91Y7I24WqX9aPS4jsqf0MaPoZgRrH5QMM0 root@tracy-virtual-machi
ne (RSA)
Creating SSH2 ECDSA key; this may take some time ...
256 SHA256:V2oe6LMKgptifgHHQ3SYTw6bEnuimlvwMPlLGFJ1NfM root@tracy-virtual-machin
e (ECDSA)
Creating SSH2 ED25519 key; this may take some time ...
256 SHA256:L/HSJjcHb0lUGB8zN2AXEuuGG3WHfJgutlRW7zgpwZ8 root@tracy-virtual-machin
e (ED25519)
Created symlink /etc/systemd/system/sshd.service → /lib/systemd/system/ssh.servi
ce.
Created symlink /etc/systemd/system/multi-user.target.wants/ssh.service → /lib/s
ystemd/system/ssh.service.
rescue-ssh.target is a disabled or a static unit, not starting it.
ssh.socket is a disabled or a static unit, not starting it.
Setting up ssh-import-id (5.11-0ubuntu1) ...
Setting up ncurses-term (6.3-2) ...
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for ufw (0.36.1-4build1) ...

2.4.4、git

sudo apt install git

root@tracy-virtual-machine:/# sudo apt install git
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following package was automatically installed and is no longer required:
  systemd-hwe-hwdb
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
  git-man liberror-perl
Suggested packages:
  git-daemon-run | git-daemon-sysvinit git-doc git-email git-gui gitk gitweb
  git-cvs git-mediawiki git-svn
The following NEW packages will be installed:
  git git-man liberror-perl
0 upgraded, 3 newly installed, 0 to remove and 187 not upgraded.
Need to get 4,112 kB of archives.
After this operation, 20.9 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://cn.archive.ubuntu.com/ubuntu jammy/main amd64 liberror-perl all 0.17029-1 [26.5 kB]
Get:2 http://cn.archive.ubuntu.com/ubuntu jammy-updates/main amd64 git-man all 1:2.34.1-1ubuntu1.5 [953 kB]
Get:3 http://cn.archive.ubuntu.com/ubuntu jammy-updates/main amd64 git amd64 1:2.34.1-1ubuntu1.5 [3,132 kB]
Fetched 4,112 kB in 16s (259 kB/s)                                             
Selecting previously unselected package liberror-perl.
(Reading database ... 200443 files and directories currently installed.)
Preparing to unpack .../liberror-perl_0.17029-1_all.deb ...
Unpacking liberror-perl (0.17029-1) ...
Selecting previously unselected package git-man.
Preparing to unpack .../git-man_1%3a2.34.1-1ubuntu1.5_all.deb ...
Unpacking git-man (1:2.34.1-1ubuntu1.5) ...
Selecting previously unselected package git.
Preparing to unpack .../git_1%3a2.34.1-1ubuntu1.5_amd64.deb ...
Unpacking git (1:2.34.1-1ubuntu1.5) ...
Setting up liberror-perl (0.17029-1) ...
Setting up git-man (1:2.34.1-1ubuntu1.5) ...
Setting up git (1:2.34.1-1ubuntu1.5) ...
Processing triggers for man-db (2.10.2-1) ...

2.4.5、tree

sudo apt install tree

root@tracy-virtual-machine:/home/aptos$ sudo apt install tree 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following package was automatically installed and is no longer required:
  systemd-hwe-hwdb
Use 'sudo apt autoremove' to remove it.
The following NEW packages will be installed:
  tree
0 upgraded, 1 newly installed, 0 to remove and 169 not upgraded.
Need to get 47.9 kB of archives.
After this operation, 116 kB of additional disk space will be used.
Get:1 http://cn.archive.ubuntu.com/ubuntu jammy/universe amd64 tree amd64 2.0.2-1 [47.9 kB]
Fetched 47.9 kB in 2s (25.5 kB/s)
Selecting previously unselected package tree.
(Reading database ... 215793 files and directories currently installed.)
Preparing to unpack .../tree_2.0.2-1_amd64.deb ...
Unpacking tree (2.0.2-1) ...
Setting up tree (2.0.2-1) ...
Processing triggers for man-db (2.10.2-1) ...

2.5、设置静态IP

在VMware Workstation中,选择菜单栏“编辑” -> "虚拟网络编辑器"

查看虚拟机网关

查看虚拟机可设置的IP段

查看虚拟机Ubuntu中当前 ip

ip addr

root@tracy-virtual-machine:/# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:83:19:3d brd ff:ff:ff:ff:ff:ff
    altname enp2s1
    inet 192.168.237.146/24 brd 192.168.237.255 scope global dynamic noprefixroute ens33
       valid_lft 1409sec preferred_lft 1409sec
    inet6 fe80::21c5:4983:13eb:6ddf/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

 编辑配置文件

sudo vim /etc/netplan/01-network-manager-all.yaml

# Let NetworkManager manage all devices on this system
network:
  ethernets:
    ens33:
      addresses: [192.168.237.170/24]
      dhcp4: no
      optional: true
      gateway4: 192.168.237.2
      nameservers:
        addresses: [8.8.8.8,8.8.4.4]
  version: 2
  renderer: NetworkManager

使配置文件生效

sudo netplan apply

root@tracy-virtual-machine:/etc/netplan# sudo netplan apply

** (generate:3468): WARNING **: 09:13:40.838: `gateway4` has been deprecated, use default routes instead.
See the 'Default routes' section of the documentation for more details.

** (process:3466): WARNING **: 09:13:41.048: `gateway4` has been deprecated, use default routes instead.
See the 'Default routes' section of the documentation for more details.

再次查看IP

ip a

root@tracy-virtual-machine:/home/tracy# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:83:19:3d brd ff:ff:ff:ff:ff:ff
    altname enp2s1
    inet 192.168.237.170/24 brd 192.168.237.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe83:193d/64 scope link 
       valid_lft forever preferred_lft forever

在Windows中使用Xshell连接Ubuntu 

 

连接时发现如下图错误 “找不到匹配的host key算法”

当前的Xshell版本是 Xshell 5,需要安装最新的Xshell 7 ,官方下载地址:Thank You - 下载 - NetSarang Website

2.6、设置屏幕休眠时间

点击左下角“Show Applications”, 右侧选择“Settings”,在弹出的Settings窗囗左侧导航中选择“Power”, 右侧Screen Blank选择休眠时间,选择Never即从不休眠。

2.7、使用FTP上传没有权限

错误如下:

修改Ubuntu文件夹权限

chmod -R 777 /home/aptos/

root@tracy-virtual-machine:/# chmod -R 777 /home/aptos/

猜你喜欢

转载自blog.csdn.net/ling1998/article/details/128024823
今日推荐