• 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

    1. tracy@tracy-virtual-machine:~$ sudo passwd
    2. [sudo] password for tracy:
    3. New password:
    4. Retype new password:
    5. passwd: password updated successfully

    切换root管理员用户 

    su root 

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

    2.4、安装

    2.4.1、vim

    apt install vim

    1. root@tracy-virtual-machine:/etc/netplan# apt install vim
    2. Reading package lists... Done
    3. Building dependency tree... Done
    4. Reading state information... Done
    5. The following package was automatically installed and is no longer required:
    6. systemd-hwe-hwdb
    7. Use 'apt autoremove' to remove it.
    8. The following additional packages will be installed:
    9. vim-common vim-runtime vim-tiny
    10. Suggested packages:
    11. ctags vim-doc vim-scripts indent
    12. The following NEW packages will be installed:
    13. vim vim-runtime
    14. The following packages will be upgraded:
    15. vim-common vim-tiny
    16. 2 upgraded, 2 newly installed, 0 to remove and 187 not upgraded.
    17. Need to get 8,560 kB/9,345 kB of archives.
    18. After this operation, 37.6 MB of additional disk space will be used.
    19. Do you want to continue? [Y/n] y
    20. Get:1 http://cn.archive.ubuntu.com/ubuntu jammy-updates/main amd64 vim-runtime all 2:8.2.3995-1ubuntu2.1 [6,832 kB]
    21. Get:2 http://cn.archive.ubuntu.com/ubuntu jammy-updates/main amd64 vim amd64 2:8.2.3995-1ubuntu2.1 [1,727 kB]
    22. Fetched 8,560 kB in 27s (316 kB/s)
    23. (Reading database ... 195626 files and directories currently installed.)
    24. Preparing to unpack .../vim-tiny_2%3a8.2.3995-1ubuntu2.1_amd64.deb ...
    25. Unpacking vim-tiny (2:8.2.3995-1ubuntu2.1) over (2:8.2.3995-1ubuntu2) ...
    26. Preparing to unpack .../vim-common_2%3a8.2.3995-1ubuntu2.1_all.deb ...
    27. Unpacking vim-common (2:8.2.3995-1ubuntu2.1) over (2:8.2.3995-1ubuntu2) ...
    28. Selecting previously unselected package vim-runtime.
    29. Preparing to unpack .../vim-runtime_2%3a8.2.3995-1ubuntu2.1_all.deb ...
    30. Adding 'diversion of /usr/share/vim/vim82/doc/help.txt to /usr/share/vim/vim82/d
    31. oc/help.txt.vim-tiny by vim-runtime'
    32. Adding 'diversion of /usr/share/vim/vim82/doc/tags to /usr/share/vim/vim82/doc/t
    33. ags.vim-tiny by vim-runtime'
    34. Unpacking vim-runtime (2:8.2.3995-1ubuntu2.1) ...
    35. Selecting previously unselected package vim.
    36. Preparing to unpack .../vim_2%3a8.2.3995-1ubuntu2.1_amd64.deb ...
    37. Unpacking vim (2:8.2.3995-1ubuntu2.1) ...
    38. Setting up vim-common (2:8.2.3995-1ubuntu2.1) ...
    39. Setting up vim-runtime (2:8.2.3995-1ubuntu2.1) ...
    40. Setting up vim (2:8.2.3995-1ubuntu2.1) ...
    41. update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vim (vim) in a
    42. uto mode
    43. update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vimdiff (vimdi
    44. ff) in auto mode
    45. update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rvim (rvim) in
    46. auto mode
    47. update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rview (rview)
    48. in auto mode
    49. update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vi (vi) in aut
    50. o mode
    51. update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/view (view) in
    52. auto mode
    53. update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/ex (ex) in aut
    54. o mode
    55. Setting up vim-tiny (2:8.2.3995-1ubuntu2.1) ...
    56. Processing triggers for mailcap (3.70+nmu1ubuntu1) ...
    57. Processing triggers for desktop-file-utils (0.26-1ubuntu3) ...
    58. Processing triggers for hicolor-icon-theme (0.17-2) ...
    59. Processing triggers for gnome-menus (3.36.0-1ubuntu3) ...
    60. Processing triggers for man-db (2.10.2-1) ...

     2.4.2、net-tools

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

    ifconfig

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

    安装net-tools 

    apt install net-tools

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

    查看ifconfig

    1. root@tracy-virtual-machine:# ifconfig
    2. ens33: flags=4163 mtu 1500
    3. inet 192.168.237.146 netmask 255.255.255.0 broadcast 192.168.237.255
    4. inet6 fe80::21c5:4983:13eb:6ddf prefixlen 64 scopeid 0x20<link>
    5. ether 00:0c:29:83:19:3d txqueuelen 1000 (Ethernet)
    6. RX packets 1487 bytes 1327857 (1.3 MB)
    7. RX errors 0 dropped 0 overruns 0 frame 0
    8. TX packets 756 bytes 58888 (58.8 KB)
    9. TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
    10. lo: flags=73 mtu 65536
    11. inet 127.0.0.1 netmask 255.0.0.0
    12. inet6 ::1 prefixlen 128 scopeid 0x10
    13. loop txqueuelen 1000 (Local Loopback)
    14. RX packets 132 bytes 11539 (11.5 KB)
    15. RX errors 0 dropped 0 overruns 0 frame 0
    16. TX packets 132 bytes 11539 (11.5 KB)
    17. TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

    2.4.3、openssh-server

    sudo apt install openssh-server

    1. root@tracy-virtual-machine:~$ sudo apt install openssh-server
    2. [sudo] password for tracy:
    3. Reading package lists... Done
    4. Building dependency tree... Done
    5. Reading state information... Done
    6. The following package was automatically installed and is no longer required:
    7. systemd-hwe-hwdb
    8. Use 'sudo apt autoremove' to remove it.
    9. The following additional packages will be installed:
    10. ncurses-term openssh-sftp-server ssh-import-id
    11. Suggested packages:
    12. molly-guard monkeysphere ssh-askpass
    13. The following NEW packages will be installed:
    14. ncurses-term openssh-server openssh-sftp-server ssh-import-id
    15. 0 upgraded, 4 newly installed, 0 to remove and 187 not upgraded.
    16. Need to get 751 kB of archives.
    17. After this operation, 6,046 kB of additional disk space will be used.
    18. Do you want to continue? [Y/n] y
    19. Get:1 http://cn.archive.ubuntu.com/ubuntu jammy/main amd64 openssh-sftp-server amd64 1:8.9p1-3 [38.8 kB]
    20. Get:2 http://cn.archive.ubuntu.com/ubuntu jammy/main amd64 openssh-server amd64 1:8.9p1-3 [434 kB]
    21. Get:3 http://cn.archive.ubuntu.com/ubuntu jammy/main amd64 ncurses-term all 6.3-2 [267 kB]
    22. Get:4 http://cn.archive.ubuntu.com/ubuntu jammy/main amd64 ssh-import-id all 5.11-0ubuntu1 [10.1 kB]
    23. Fetched 751 kB in 5s (166 kB/s)
    24. Preconfiguring packages ...
    25. Selecting previously unselected package openssh-sftp-server.
    26. (Reading database ... 197567 files and directories currently installed.)
    27. Preparing to unpack .../openssh-sftp-server_1%3a8.9p1-3_amd64.deb ...
    28. Unpacking openssh-sftp-server (1:8.9p1-3) ...
    29. Selecting previously unselected package openssh-server.
    30. Preparing to unpack .../openssh-server_1%3a8.9p1-3_amd64.deb ...
    31. Unpacking openssh-server (1:8.9p1-3) ...
    32. Selecting previously unselected package ncurses-term.
    33. Preparing to unpack .../ncurses-term_6.3-2_all.deb ...
    34. Unpacking ncurses-term (6.3-2) ...
    35. Selecting previously unselected package ssh-import-id.
    36. Preparing to unpack .../ssh-import-id_5.11-0ubuntu1_all.deb ...
    37. Unpacking ssh-import-id (5.11-0ubuntu1) ...
    38. Setting up openssh-sftp-server (1:8.9p1-3) ...
    39. Setting up openssh-server (1:8.9p1-3) ...
    40. Creating config file /etc/ssh/sshd_config with new version
    41. Creating SSH2 RSA key; this may take some time ...
    42. 3072 SHA256:QLlC3ZcCw91Y7I24WqX9aPS4jsqf0MaPoZgRrH5QMM0 root@tracy-virtual-machi
    43. ne (RSA)
    44. Creating SSH2 ECDSA key; this may take some time ...
    45. 256 SHA256:V2oe6LMKgptifgHHQ3SYTw6bEnuimlvwMPlLGFJ1NfM root@tracy-virtual-machin
    46. e (ECDSA)
    47. Creating SSH2 ED25519 key; this may take some time ...
    48. 256 SHA256:L/HSJjcHb0lUGB8zN2AXEuuGG3WHfJgutlRW7zgpwZ8 root@tracy-virtual-machin
    49. e (ED25519)
    50. Created symlink /etc/systemd/system/sshd.service → /lib/systemd/system/ssh.servi
    51. ce.
    52. Created symlink /etc/systemd/system/multi-user.target.wants/ssh.service → /lib/s
    53. ystemd/system/ssh.service.
    54. rescue-ssh.target is a disabled or a static unit, not starting it.
    55. ssh.socket is a disabled or a static unit, not starting it.
    56. Setting up ssh-import-id (5.11-0ubuntu1) ...
    57. Setting up ncurses-term (6.3-2) ...
    58. Processing triggers for man-db (2.10.2-1) ...
    59. Processing triggers for ufw (0.36.1-4build1) ...

    2.4.4、git

    sudo apt install git

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

    2.4.5、tree

    sudo apt install tree

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

    2.5、设置静态IP

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

    查看虚拟机网关

    查看虚拟机可设置的IP段

    查看虚拟机Ubuntu中当前 ip

    ip addr

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

     编辑配置文件

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

    1. # Let NetworkManager manage all devices on this system
    2. network:
    3. ethernets:
    4. ens33:
    5. addresses: [192.168.237.170/24]
    6. dhcp4: no
    7. optional: true
    8. gateway4: 192.168.237.2
    9. nameservers:
    10. addresses: [8.8.8.8,8.8.4.4]
    11. version: 2
    12. renderer: NetworkManager

    使配置文件生效

    sudo netplan apply

    1. root@tracy-virtual-machine:/etc/netplan# sudo netplan apply
    2. ** (generate:3468): WARNING **: 09:13:40.838: `gateway4` has been deprecated, use default routes instead.
    3. See the 'Default routes' section of the documentation for more details.
    4. ** (process:3466): WARNING **: 09:13:41.048: `gateway4` has been deprecated, use default routes instead.
    5. See the 'Default routes' section of the documentation for more details.

    再次查看IP

    ip a

    1. root@tracy-virtual-machine:/home/tracy# ip a
    2. 1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    3. link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    4. inet 127.0.0.1/8 scope host lo
    5. valid_lft forever preferred_lft forever
    6. inet6 ::1/128 scope host
    7. valid_lft forever preferred_lft forever
    8. 2: ens33: mtu 1500 qdisc fq_codel state UP group default qlen 1000
    9. link/ether 00:0c:29:83:19:3d brd ff:ff:ff:ff:ff:ff
    10. altname enp2s1
    11. inet 192.168.237.170/24 brd 192.168.237.255 scope global noprefixroute ens33
    12. valid_lft forever preferred_lft forever
    13. inet6 fe80::20c:29ff:fe83:193d/64 scope link
    14. 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/

  • 相关阅读:
    【linux基础命令(2)】
    C++中静态成员和非静态成员
    使用 ahooks 中的 useRequest 轻松管理React中的网络请求
    Java - postman访问登录接口失败 (cookie会话不一致)
    【面经】如何使用less命令查看和搜索日志
    第四代智能井盖传感器:万宾科技智能井盖位移监测方式一览
    【owt】owt-client-native-p2p-e2e-test vs2017构建2 :测试单元构建及运行
    「刷起来」Go必看的进阶面试题详解
    深度学习入门(十) 模型选择、过拟合和欠拟合
    【教程】使用vuepress构建静态文档网站,并部署到github上
  • 原文地址:https://blog.csdn.net/ling1998/article/details/128024823