当前位置: 首页 > news >正文

公司网站地址徐州鼓楼区建设网站

公司网站地址,徐州鼓楼区建设网站,东阳网站建设yw81,网站建设设计摘要19 Linux之Python定制篇-apt软件管理和远程登录 文章目录 19 Linux之Python定制篇-apt软件管理和远程登录19.1 apt软件管理19.1.1 apt介绍19.1.2 更新软件下载地址-阿里源19.1.3 使用apt完成安装和卸载vim 19.2 远程登录Ubuntu 学习视频来自于B站【小白入门 通俗易懂】2021韩顺…19 Linux之Python定制篇-apt软件管理和远程登录 文章目录 19 Linux之Python定制篇-apt软件管理和远程登录19.1 apt软件管理19.1.1 apt介绍19.1.2 更新软件下载地址-阿里源19.1.3 使用apt完成安装和卸载vim 19.2 远程登录Ubuntu 学习视频来自于B站【小白入门 通俗易懂】2021韩顺平 一周学会Linux。可能会用到的资料有如下所示下载链接见文末 《鸟哥的Linux私房菜 基础学习篇 第四版》1《鸟哥的Linux私房菜 服务器架设篇 第三版》2《韩顺平_2021图解Linux全面升级》3 19.1 apt软件管理 19.1.1 apt介绍 apt是Advanced Packaging Tool的简称是一款应用在Ubuntu、Debian和相关Linux发行版上安装包管理工具。在Ubuntu下我们可以使用apt命令很方便的进行软件包的安装、删除、清理等类似于Windows中的软件管理工具(如“360软件管家”)。比如下面给出了Ubuntu下 apt软件操作相关指令 (带*号的都是重点) # 带*号的是重点 sudo apt-get update #*更新源 sudo apt-get install package #*安装包 sudo apt-get remove package #*删除包sudo apt-cache search package # 搜索软件包 sudo apt-cache show package #*获取包的相关信息如说明、大小、版本等 sudo apt-get install package --reinstall # 重新安装包sudo apt-get -f install # 修复安装 sudo apt-get remove package --purge # 删除包,包括配置文件等 sudo apt-get build-dep package # 安装相关的编译环境sudo apt-get upgrade # 更新已安装的包 sudo apt-get dist-upgrade # 升级系统 sudo apt-cache depends package # 了解使用该包依赖那些包 sudo apt-cache rdepends package # 查看该包被哪些包依赖 sudo apt-get source package #*下载该包的源代码比如现在我们要安装Vim编辑器只需输入下面的一行代码就可以一键完成了 sudo apt-get install vim但是不出意外的话在没有更新软件下载地址的情况下大部分人此时肯定会下载失败或者下载巨慢下一节就来解释为什么。 19.1.2 更新软件下载地址-阿里源 上一小节提到在没有更新软件下载地址的情况下大部分人使用apt下载软件是常常会下载失败或者下载巨慢这是因为Ubuntu预装的软件下载地址(/etc/apt/sources.list)存储的都是美国的APT服务器地址。这个“APT服务器地址”可以理解成下载软件的地方比如Android手机上可以下载软件的“应用商店”、ios手机上可以下载软件的“AppStore”。那这个“应用商店”在美国在国内使用Ubuntu访问肯定会极其不稳定啦。 为了解决这个问题、方便广大Linux开发者国内很多大公司高校就将美国APT服务器的东西全部搬到自己的网页上做成镜像网站也就相当于国内的“应用商店”。此时只需要将Ubuntu默认存储的软件下载地址切换成国内的镜像源网址就可以很方便的实现软件的安装了如下图所示。 #mermaid-svg-wVpRDzYu8Chth76c {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-wVpRDzYu8Chth76c .error-icon{fill:#552222;}#mermaid-svg-wVpRDzYu8Chth76c .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-wVpRDzYu8Chth76c .edge-thickness-normal{stroke-width:2px;}#mermaid-svg-wVpRDzYu8Chth76c .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-wVpRDzYu8Chth76c .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-wVpRDzYu8Chth76c .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-wVpRDzYu8Chth76c .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-wVpRDzYu8Chth76c .marker{fill:#333333;stroke:#333333;}#mermaid-svg-wVpRDzYu8Chth76c .marker.cross{stroke:#333333;}#mermaid-svg-wVpRDzYu8Chth76c svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-wVpRDzYu8Chth76c .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-wVpRDzYu8Chth76c .cluster-label text{fill:#333;}#mermaid-svg-wVpRDzYu8Chth76c .cluster-label span{color:#333;}#mermaid-svg-wVpRDzYu8Chth76c .label text,#mermaid-svg-wVpRDzYu8Chth76c span{fill:#333;color:#333;}#mermaid-svg-wVpRDzYu8Chth76c .node rect,#mermaid-svg-wVpRDzYu8Chth76c .node circle,#mermaid-svg-wVpRDzYu8Chth76c .node ellipse,#mermaid-svg-wVpRDzYu8Chth76c .node polygon,#mermaid-svg-wVpRDzYu8Chth76c .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-wVpRDzYu8Chth76c .node .label{text-align:center;}#mermaid-svg-wVpRDzYu8Chth76c .node.clickable{cursor:pointer;}#mermaid-svg-wVpRDzYu8Chth76c .arrowheadPath{fill:#333333;}#mermaid-svg-wVpRDzYu8Chth76c .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-wVpRDzYu8Chth76c .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-wVpRDzYu8Chth76c .edgeLabel{background-color:#e8e8e8;text-align:center;}#mermaid-svg-wVpRDzYu8Chth76c .edgeLabel rect{opacity:0.5;background-color:#e8e8e8;fill:#e8e8e8;}#mermaid-svg-wVpRDzYu8Chth76c .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-wVpRDzYu8Chth76c .cluster text{fill:#333;}#mermaid-svg-wVpRDzYu8Chth76c .cluster span{color:#333;}#mermaid-svg-wVpRDzYu8Chth76c div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-wVpRDzYu8Chth76c :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 互联网 连接稳定 定期更新 连接不稳定不推荐 国内APT的镜像网站清华大学阿里云腾讯云... 境外的APT服务器(美国) Ubantu系统/etc/apt/sources.list存储软件下载地址 网关 图19-1 APT软件管理示意图 下面列出一些常见的镜像源地址 阿里云https://developer.aliyun.com/mirror清华大学https://mirrors.tuna.tsinghua.edu.cn/ 注更多国内的镜像源可以参考CSDN博文“国内镜像网站列表”。 吐槽我刚安装好Ubuntu的时候没更新源倒霉催的啥也装不上(比如Vim)。结果按照老韩说的一步步来更新源吧最后到复制地址到文件的时候居然不能复制查了一下大概是虚拟机和Windows主机不共享剪贴板解决了一圈没解决。我想这直接虚拟机上网复制不就好了结果不知道为啥虚拟机又不能上网了。TND我只好删除再重新安装Ubuntu虚拟机好在可以虚拟机可以复制粘贴主机上的内容了。这一把我啥也不敢耽误直接去更新老韩说的“清华大学镜像源”TND的更新源的时候总是失败。最后没办法我换了阿里源才终于更新好了。所以下面我演示的是更新阿里源。 打开镜像源网站后找到Ubuntu对应的连接(网页搜索ctrlf更快搜索)就可以找到对应的镜像地址了如下图所示。注意一定要复制对应版本的镜像源比如Ubuntu20.04.3就复制阿里源20.04(focal)镜像源。 图19-2 清华大学的Ubuntu20.04.1镜像源 图19-3 阿里云的Ubuntu20.04.1镜像源 现在就演示如何将/etc/apt/sources.list文件中的美国服务器地址全改成阿里云的镜像源地址 # 指令速览 # 1. 备份原来的镜像源地址文件 sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup# 2. 清空当前的镜像源文件 echo /etc/apt/sources.list# 3. 将阿里源的内容复制到镜像源文件中 vi sources.list ################################################################ # 打开后进入vi编辑器不熟悉的同学可以百度“vi编辑器”自行了解一下。 按i键 进入编辑模式 鼠标复制网站上的镜像源内容然后用鼠标右键粘贴到文件中。 按下esc键 输入:wq 意为保存并退出 ################################################################# 4. 告诉系统更新源 sudo apt-get update下面是实际的终端演示 # 1. 为了方便切换成root用户并切换到/etc/apt目录 lylubuntu:~/Desktop$ su root Password: rootubuntu:/home/lyl/Desktop# cd /etc/apt# 2. 备份原来的镜像源地址文件 rootubuntu:/etc/apt# ls apt.conf.d preferences.d sources.list trusted.gpg.d auth.conf.d sources.bak sources.list.d rootubuntu:/etc/apt# cp sources.list sources.list.backup rootubuntu:/etc/apt# ls apt.conf.d preferences.d sources.list sources.list.d auth.conf.d sources.bak sources.list.backup trusted.gpg.d# 3. 清空当前的镜像源文件 rootubuntu:/etc/apt# echo sources.list# 4. 将阿里源的内容复制到镜像源文件中 rootubuntu:/etc/apt# vi sources.list ################################################################ # 打开后进入vi编辑器不熟悉的同学可以百度“vi编辑器”自行了解一下。 # 使用vi是假设之前网不好没装上vim 按i键 进入编辑模式 鼠标复制网站上的镜像源内容然后用鼠标右键粘贴到文件中。 按下esc键 输入:wq 意为保存并退出 ################################################################# 5. 告诉系统更新源 rootubuntu:/etc/apt# sudo apt-get update Get:1 https://mirrors.aliyun.com/ubuntu focal InRelease [265 kB] Get:2 https://mirrors.aliyun.com/ubuntu focal-security InRelease [114 kB] Get:3 https://mirrors.aliyun.com/ubuntu focal-updates InRelease [114 kB] Get:4 https://mirrors.aliyun.com/ubuntu focal-backports InRelease [108 kB] Get:5 https://mirrors.aliyun.com/ubuntu focal/universe Sources [9,707 kB] Get:6 https://mirrors.aliyun.com/ubuntu focal/restricted Sources [6,472 B] Get:7 https://mirrors.aliyun.com/ubuntu focal/main Sources [847 kB] Get:8 https://mirrors.aliyun.com/ubuntu focal/multiverse Sources [174 kB] Get:9 https://mirrors.aliyun.com/ubuntu focal/main i386 Packages [718 kB] Get:10 https://mirrors.aliyun.com/ubuntu focal/main amd64 Packages [970 kB] Get:11 https://mirrors.aliyun.com/ubuntu focal/main Translation-en [506 kB] Get:12 https://mirrors.aliyun.com/ubuntu focal/main amd64 DEP-11 Metadata [494 kB] Get:13 https://mirrors.aliyun.com/ubuntu focal/main DEP-11 48x48 Icons [98.4 kB] Get:14 https://mirrors.aliyun.com/ubuntu focal/main DEP-11 64x64 Icons [163 kB] Get:15 https://mirrors.aliyun.com/ubuntu focal/main DEP-11 64x642 Icons [15.8 kB] Get:16 https://mirrors.aliyun.com/ubuntu focal/main amd64 c-n-f Metadata [29.5 kB] Get:17 https://mirrors.aliyun.com/ubuntu focal/restricted i386 Packages [8,112 B] Get:18 https://mirrors.aliyun.com/ubuntu focal/restricted amd64 Packages [22.0 kB] Get:19 https://mirrors.aliyun.com/ubuntu focal/restricted Translation-en [6,212 B] Get:20 https://mirrors.aliyun.com/ubuntu focal/restricted amd64 c-n-f Metadata [392 B] Get:21 https://mirrors.aliyun.com/ubuntu focal/universe i386 Packages [4,642 kB] Get:22 https://mirrors.aliyun.com/ubuntu focal/universe amd64 Packages [8,628 kB] Get:23 https://mirrors.aliyun.com/ubuntu focal/universe Translation-en [5,124 kB] Get:24 https://mirrors.aliyun.com/ubuntu focal/universe amd64 DEP-11 Metadata [3,603 kB] Get:25 https://mirrors.aliyun.com/ubuntu focal/universe DEP-11 48x48 Icons [3,016 kB] Get:26 https://mirrors.aliyun.com/ubuntu focal/universe DEP-11 64x64 Icons [7,794 kB] Get:27 https://mirrors.aliyun.com/ubuntu focal/universe DEP-11 64x642 Icons [44.3 kB] Get:28 https://mirrors.aliyun.com/ubuntu focal/universe amd64 c-n-f Metadata [265 kB] Get:29 https://mirrors.aliyun.com/ubuntu focal/multiverse amd64 Packages [144 kB] Get:30 https://mirrors.aliyun.com/ubuntu focal/multiverse i386 Packages [74.7 kB] Get:31 https://mirrors.aliyun.com/ubuntu focal/multiverse Translation-en [104 kB] Get:32 https://mirrors.aliyun.com/ubuntu focal/multiverse amd64 DEP-11 Metadata [48.4 kB] Get:33 https://mirrors.aliyun.com/ubuntu focal/multiverse DEP-11 48x48 Icons [23.1 kB] Get:34 https://mirrors.aliyun.com/ubuntu focal/multiverse DEP-11 64x64 Icons [192 kB] Get:35 https://mirrors.aliyun.com/ubuntu focal/multiverse DEP-11 64x642 Icons [214 B] Get:36 https://mirrors.aliyun.com/ubuntu focal/multiverse amd64 c-n-f Metadata [9,136 B] Get:37 https://mirrors.aliyun.com/ubuntu focal-security/main Sources [289 kB] Get:38 https://mirrors.aliyun.com/ubuntu focal-security/universe Sources [192 kB] Get:39 https://mirrors.aliyun.com/ubuntu focal-security/restricted Sources [54.1 kB] Get:40 https://mirrors.aliyun.com/ubuntu focal-security/multiverse Sources [13.8 kB] Get:41 https://mirrors.aliyun.com/ubuntu focal-security/main amd64 Packages [2,362 kB] Get:42 https://mirrors.aliyun.com/ubuntu focal-security/main i386 Packages [632 kB] Get:43 https://mirrors.aliyun.com/ubuntu focal-security/main Translation-en [373 kB] Get:44 https://mirrors.aliyun.com/ubuntu focal-security/main amd64 DEP-11 Metadata [59.9 kB] Get:45 https://mirrors.aliyun.com/ubuntu focal-security/main DEP-11 48x48 Icons [18.9 kB] Get:46 https://mirrors.aliyun.com/ubuntu focal-security/main DEP-11 64x64 Icons [36.0 kB] Get:47 https://mirrors.aliyun.com/ubuntu focal-security/main DEP-11 64x642 Icons [29 B] Get:48 https://mirrors.aliyun.com/ubuntu focal-security/main amd64 c-n-f Metadata [13.0 kB] Get:49 https://mirrors.aliyun.com/ubuntu focal-security/restricted amd64 Packages [2,070 kB] Get:50 https://mirrors.aliyun.com/ubuntu focal-security/restricted i386 Packages [32.3 kB] Get:51 https://mirrors.aliyun.com/ubuntu focal-security/restricted Translation-en [289 kB] Get:52 https://mirrors.aliyun.com/ubuntu focal-security/restricted amd64 c-n-f Metadata [580 B] Get:53 https://mirrors.aliyun.com/ubuntu focal-security/universe i386 Packages [611 kB] Get:54 https://mirrors.aliyun.com/ubuntu focal-security/universe amd64 Packages [872 kB] Get:55 https://mirrors.aliyun.com/ubuntu focal-security/universe Translation-en [183 kB] Get:56 https://mirrors.aliyun.com/ubuntu focal-security/universe amd64 DEP-11 Metadata [96.3 kB] Get:57 https://mirrors.aliyun.com/ubuntu focal-security/universe DEP-11 48x48 Icons [52.0 kB] Get:58 https://mirrors.aliyun.com/ubuntu focal-security/universe DEP-11 64x64 Icons [101 kB] Get:59 https://mirrors.aliyun.com/ubuntu focal-security/universe DEP-11 64x642 Icons [29 B] Get:60 https://mirrors.aliyun.com/ubuntu focal-security/universe amd64 c-n-f Metadata [19.0 kB] Get:61 https://mirrors.aliyun.com/ubuntu focal-security/multiverse amd64 Packages [23.6 kB] Get:62 https://mirrors.aliyun.com/ubuntu focal-security/multiverse i386 Packages [7,196 B] Get:63 https://mirrors.aliyun.com/ubuntu focal-security/multiverse Translation-en [5,504 B] Get:64 https://mirrors.aliyun.com/ubuntu focal-security/multiverse amd64 DEP-11 Metadata [940 B] Get:65 https://mirrors.aliyun.com/ubuntu focal-security/multiverse DEP-11 48x48 Icons [1,867 B] Get:66 https://mirrors.aliyun.com/ubuntu focal-security/multiverse DEP-11 64x64 Icons [2,497 B] Get:67 https://mirrors.aliyun.com/ubuntu focal-security/multiverse DEP-11 64x642 Icons [29 B] Get:68 https://mirrors.aliyun.com/ubuntu focal-security/multiverse amd64 c-n-f Metadata [548 B] Get:69 https://mirrors.aliyun.com/ubuntu focal-updates/restricted Sources [54.2 kB] Get:70 https://mirrors.aliyun.com/ubuntu focal-updates/main Sources [571 kB] Get:71 https://mirrors.aliyun.com/ubuntu focal-updates/universe Sources [342 kB] Get:72 https://mirrors.aliyun.com/ubuntu focal-updates/multiverse Sources [24.4 kB] Get:73 https://mirrors.aliyun.com/ubuntu focal-updates/main i386 Packages [864 kB] Get:74 https://mirrors.aliyun.com/ubuntu focal-updates/main amd64 Packages [2,753 kB] Get:75 https://mirrors.aliyun.com/ubuntu focal-updates/main Translation-en [456 kB] Get:76 https://mirrors.aliyun.com/ubuntu focal-updates/main amd64 DEP-11 Metadata [275 kB] Get:77 https://mirrors.aliyun.com/ubuntu focal-updates/main DEP-11 48x48 Icons [60.8 kB] Get:78 https://mirrors.aliyun.com/ubuntu focal-updates/main DEP-11 64x64 Icons [98.3 kB] Get:79 https://mirrors.aliyun.com/ubuntu focal-updates/main DEP-11 64x642 Icons [29 B] Get:80 https://mirrors.aliyun.com/ubuntu focal-updates/main amd64 c-n-f Metadata [17.0 kB] Get:81 https://mirrors.aliyun.com/ubuntu focal-updates/restricted i386 Packages [33.7 kB] Get:82 https://mirrors.aliyun.com/ubuntu focal-updates/restricted amd64 Packages [2,185 kB] Get:83 https://mirrors.aliyun.com/ubuntu focal-updates/restricted Translation-en [306 kB] Get:84 https://mirrors.aliyun.com/ubuntu focal-updates/restricted amd64 c-n-f Metadata [576 B] Get:85 https://mirrors.aliyun.com/ubuntu focal-updates/universe i386 Packages [744 kB] Get:86 https://mirrors.aliyun.com/ubuntu focal-updates/universe amd64 Packages [1,101 kB] Get:87 https://mirrors.aliyun.com/ubuntu focal-updates/universe Translation-en [263 kB] Get:88 https://mirrors.aliyun.com/ubuntu focal-updates/universe amd64 DEP-11 Metadata [410 kB] Get:89 https://mirrors.aliyun.com/ubuntu focal-updates/universe DEP-11 48x48 Icons [280 kB] Get:90 https://mirrors.aliyun.com/ubuntu focal-updates/universe DEP-11 64x64 Icons [493 kB] Get:91 https://mirrors.aliyun.com/ubuntu focal-updates/universe DEP-11 64x642 Icons [29 B] Get:92 https://mirrors.aliyun.com/ubuntu focal-updates/universe amd64 c-n-f Metadata [25.5 kB] Get:93 https://mirrors.aliyun.com/ubuntu focal-updates/multiverse amd64 Packages [25.8 kB] Get:94 https://mirrors.aliyun.com/ubuntu focal-updates/multiverse i386 Packages [8,436 B] Get:95 https://mirrors.aliyun.com/ubuntu focal-updates/multiverse Translation-en [7,484 B] Get:96 https://mirrors.aliyun.com/ubuntu focal-updates/multiverse amd64 DEP-11 Metadata [940 B] Get:97 https://mirrors.aliyun.com/ubuntu focal-updates/multiverse DEP-11 48x48 Icons [1,867 B] Get:98 https://mirrors.aliyun.com/ubuntu focal-updates/multiverse DEP-11 64x64 Icons [2,497 B] Get:99 https://mirrors.aliyun.com/ubuntu focal-updates/multiverse DEP-11 64x642 Icons [29 B] Get:100 https://mirrors.aliyun.com/ubuntu focal-updates/multiverse amd64 c-n-f Metadata [620 B] Get:101 https://mirrors.aliyun.com/ubuntu focal-backports/main Sources [9,608 B] Get:102 https://mirrors.aliyun.com/ubuntu focal-backports/universe Sources [10.5 kB] Get:103 https://mirrors.aliyun.com/ubuntu focal-backports/main amd64 Packages [45.7 kB] Get:104 https://mirrors.aliyun.com/ubuntu focal-backports/main i386 Packages [36.1 kB] Get:105 https://mirrors.aliyun.com/ubuntu focal-backports/main Translation-en [16.3 kB] Get:106 https://mirrors.aliyun.com/ubuntu focal-backports/main amd64 DEP-11 Metadata [7,968 B] Get:107 https://mirrors.aliyun.com/ubuntu focal-backports/main DEP-11 48x48 Icons [7,156 B] Get:108 https://mirrors.aliyun.com/ubuntu focal-backports/main DEP-11 64x64 Icons [10.7 kB] Get:109 https://mirrors.aliyun.com/ubuntu focal-backports/main DEP-11 64x642 Icons [29 B] Get:110 https://mirrors.aliyun.com/ubuntu focal-backports/main amd64 c-n-f Metadata [1,420 B] Get:111 https://mirrors.aliyun.com/ubuntu focal-backports/restricted amd64 c-n-f Metadata [116 B] Get:112 https://mirrors.aliyun.com/ubuntu focal-backports/universe i386 Packages [13.8 kB] Get:113 https://mirrors.aliyun.com/ubuntu focal-backports/universe amd64 Packages [25.0 kB] Get:114 https://mirrors.aliyun.com/ubuntu focal-backports/universe Translation-en [16.3 kB] Get:115 https://mirrors.aliyun.com/ubuntu focal-backports/universe amd64 DEP-11 Metadata [30.5 kB] Get:116 https://mirrors.aliyun.com/ubuntu focal-backports/universe DEP-11 48x48 Icons [13.3 kB] Get:117 https://mirrors.aliyun.com/ubuntu focal-backports/universe DEP-11 64x64 Icons [22.7 kB] Get:118 https://mirrors.aliyun.com/ubuntu focal-backports/universe DEP-11 64x642 Icons [29 B] Get:119 https://mirrors.aliyun.com/ubuntu focal-backports/universe amd64 c-n-f Metadata [880 B] Get:120 https://mirrors.aliyun.com/ubuntu focal-backports/multiverse amd64 c-n-f Metadata [116 B] Fetched 68.2 MB in 18s (3,864 kB/s) Reading package lists... Done # 看到Done就证明更新成功19.1.3 使用apt完成安装和卸载vim 本节以常用的Vim编辑器这款软件为例演示如何使用apt完成软件的安装、卸载、查询软件信息。下面给出指令速览 # 1. 安装Vim sudo apt-get install vim # 2. 安装Vim完成后使用Vim创建hello.txt验证可以正常使用vim指令 vim hello.txt # 3. 查看Vim的安装信息 sudo apt-cache show vim # 4. 删除Vim(选做) sudo apt-get remove vim下面是实际的终端演示 # 1. 首先验证没有安装Vim之前是无法使用Vim指令的 lylubuntu:~/Desktop$ vim hello.txtCommand vim not found, but can be installed with:sudo apt install vim # version 2:8.1.2269-1ubuntu5.16, or sudo apt install vim-tiny # version 2:8.1.2269-1ubuntu5.16 sudo apt install neovim # version 0.4.3-3 sudo apt install vim-athena # version 2:8.1.2269-1ubuntu5.16 sudo apt install vim-gtk3 # version 2:8.1.2269-1ubuntu5.16 sudo apt install vim-nox # version 2:8.1.2269-1ubuntu5.16# 2. 安装Vim lylubuntu:~/Desktop$ sudo apt-get install vim Reading package lists... Done Building dependency tree Reading state information... Done 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 578 not upgraded. Need to get 7,787 kB of archives. After this operation, 34.6 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 https://mirrors.aliyun.com/ubuntu focal-security/main amd64 vim-tiny amd64 2:8.1.2269-1ubuntu5.16 [581 kB] Get:2 https://mirrors.aliyun.com/ubuntu focal-security/main amd64 vim-common all 2:8.1.2269-1ubuntu5.16 [87.2 kB] Get:3 https://mirrors.aliyun.com/ubuntu focal-security/main amd64 vim-runtime all 2:8.1.2269-1ubuntu5.16 [5,878 kB] Get:4 https://mirrors.aliyun.com/ubuntu focal-security/main amd64 vim amd64 2:8.1.2269-1ubuntu5.16 [1,241 kB] Fetched 7,787 kB in 1s (8,606 kB/s) (Reading database ... 156930 files and directories currently installed.) Preparing to unpack .../vim-tiny_2%3a8.1.2269-1ubuntu5.16_amd64.deb ... Unpacking vim-tiny (2:8.1.2269-1ubuntu5.16) over (2:8.1.2269-1ubuntu5) ... Preparing to unpack .../vim-common_2%3a8.1.2269-1ubuntu5.16_all.deb ... Unpacking vim-common (2:8.1.2269-1ubuntu5.16) over (2:8.1.2269-1ubuntu5) ... Selecting previously unselected package vim-runtime. Preparing to unpack .../vim-runtime_2%3a8.1.2269-1ubuntu5.16_all.deb ... Adding diversion of /usr/share/vim/vim81/doc/help.txt to /usr/share/vim/vim81/doc/help.txt.vim-tiny by vim-runtime Adding diversion of /usr/share/vim/vim81/doc/tags to /usr/share/vim/vim81/doc/tags.vim-tiny by vim-runtime Unpacking vim-runtime (2:8.1.2269-1ubuntu5.16) ... Selecting previously unselected package vim. Preparing to unpack .../vim_2%3a8.1.2269-1ubuntu5.16_amd64.deb ... Unpacking vim (2:8.1.2269-1ubuntu5.16) ... Setting up vim-common (2:8.1.2269-1ubuntu5.16) ... Setting up vim-runtime (2:8.1.2269-1ubuntu5.16) ... Setting up vim (2:8.1.2269-1ubuntu5.16) ... update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vim (vim) in auto mode update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vimdiff (vimdiff) 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 auto 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 auto mode Setting up vim-tiny (2:8.1.2269-1ubuntu5.16) ... Processing triggers for desktop-file-utils (0.24-1ubuntu3) ... Processing triggers for mime-support (3.64ubuntu1) ... Processing triggers for hicolor-icon-theme (0.17-2) ... Processing triggers for gnome-menus (3.36.0-1ubuntu1) ... Processing triggers for man-db (2.9.1-1) ...# 3. 安装Vim完成后使用Vim创建hello.txt并验证 lylubuntu:~/Desktop$ vim hello.txt ################################### # Vim编辑器写上hello,vim! ################################### lylubuntu:~/Desktop$ cat hello.txt hello,vim!# 4. 还可以查看Vim的安装信息 lylubuntu:~/Desktop$ sudo apt-cache show vim Package: vim Architecture: amd64 Version: 2:8.1.2269-1ubuntu5.16 Priority: optional Section: editors Origin: Ubuntu Maintainer: Ubuntu Developers ubuntu-devel-discusslists.ubuntu.com Original-Maintainer: Debian Vim Maintainers pkg-vim-maintainerslists.alioth.debian.org Bugs: https://bugs.launchpad.net/ubuntu/filebug Installed-Size: 3046 Provides: editor Depends: vim-common ( 2:8.1.2269-1ubuntu5.16), vim-runtime ( 2:8.1.2269-1ubuntu5.16), libacl1 ( 2.2.23), libc6 ( 2.29), libcanberra0 ( 0.2), libgpm2 ( 1.20.7), libpython3.8 ( 3.8.2), libselinux1 ( 1.32), libtinfo6 ( 6) Suggests: ctags, vim-doc, vim-scripts Filename: pool/main/v/vim/vim_8.1.2269-1ubuntu5.16_amd64.deb Size: 1240908 MD5sum: ab9e41ee56638f5fd750f15cafaffcec SHA1: 52dd1e72a54c753b1520e5dda3b5f83df84e5d91 SHA256: 699c0a3e7931022b68f7e805ad53cbfd49b135a86fd8dd94d737a539c99f2477 SHA512: dfa74ddca1ca1e46306c946f0025bb657e9edce773caea90816720d3c5c10fd83c65fcdd39e3a6931accccf5a2a4d288ba41f014763bd15a9d558d41896b809d Homepage: https://www.vim.org/ Description-en: Vi IMproved - enhanced vi editorVim is an almost compatible version of the UNIX editor Vi..Many new features have been added: multi level undo, syntaxhighlighting, command line history, on-line help, filenamecompletion, block operations, folding, Unicode support, etc..This package contains a version of vim compiled with a ratherstandard set of features. This package does not provide a GUIversion of Vim. See the other vim-* packages if you need more(or less). Description-md5: 59e8b8f7757db8b53566d5d119872de8 Task: server, cloud-image, lubuntu-desktop注安装过程中可以体会到因为使用了镜像网站软件下载速度很快。 19.2 远程登录Ubuntu 那一般进行软件开发时肯定是用自己的电脑最习惯而不是直接在Ubuntu上敲代码所以Ubuntu的最后一节来讲讲如何远程登录Ubuntu。和CentOS自带远程登录服务不同Ubuntu上默认没有安装“SSH服务”所以使用Putty或Xshell等工具远程连接Ubuntu时会遇到拒绝连接服务。SSH为Secure Shell的缩写由IETF的网络工作小组(Network Working Group)所制定是一种建立在应用层和传输层基础上的安全协议。SSH是目前较可靠专为远程登录会话和其他网络服务提供安全性的协议几乎所有UNIX/Linux平台都可运行SSH。 #mermaid-svg-BO8znxwEbfe8jnav {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-BO8znxwEbfe8jnav .error-icon{fill:#552222;}#mermaid-svg-BO8znxwEbfe8jnav .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-BO8znxwEbfe8jnav .edge-thickness-normal{stroke-width:2px;}#mermaid-svg-BO8znxwEbfe8jnav .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-BO8znxwEbfe8jnav .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-BO8znxwEbfe8jnav .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-BO8znxwEbfe8jnav .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-BO8znxwEbfe8jnav .marker{fill:#333333;stroke:#333333;}#mermaid-svg-BO8znxwEbfe8jnav .marker.cross{stroke:#333333;}#mermaid-svg-BO8znxwEbfe8jnav svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-BO8znxwEbfe8jnav .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-BO8znxwEbfe8jnav .cluster-label text{fill:#333;}#mermaid-svg-BO8znxwEbfe8jnav .cluster-label span{color:#333;}#mermaid-svg-BO8znxwEbfe8jnav .label text,#mermaid-svg-BO8znxwEbfe8jnav span{fill:#333;color:#333;}#mermaid-svg-BO8znxwEbfe8jnav .node rect,#mermaid-svg-BO8znxwEbfe8jnav .node circle,#mermaid-svg-BO8znxwEbfe8jnav .node ellipse,#mermaid-svg-BO8znxwEbfe8jnav .node polygon,#mermaid-svg-BO8znxwEbfe8jnav .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-BO8znxwEbfe8jnav .node .label{text-align:center;}#mermaid-svg-BO8znxwEbfe8jnav .node.clickable{cursor:pointer;}#mermaid-svg-BO8znxwEbfe8jnav .arrowheadPath{fill:#333333;}#mermaid-svg-BO8znxwEbfe8jnav .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-BO8znxwEbfe8jnav .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-BO8znxwEbfe8jnav .edgeLabel{background-color:#e8e8e8;text-align:center;}#mermaid-svg-BO8znxwEbfe8jnav .edgeLabel rect{opacity:0.5;background-color:#e8e8e8;fill:#e8e8e8;}#mermaid-svg-BO8znxwEbfe8jnav .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-BO8znxwEbfe8jnav .cluster text{fill:#333;}#mermaid-svg-BO8znxwEbfe8jnav .cluster span{color:#333;}#mermaid-svg-BO8znxwEbfe8jnav div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-BO8znxwEbfe8jnav :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} Linux系统-UbuntuB Linux系统-UbuntuA Windows系统 SSH客户端(ssh) 端口22 SSH服务器端(sshd) SSH客户端如Xshell6 图19-3 SSH远程登录示意图 严格来说使用SSH服务需要安装相应的“服务器端(sshd)”和“客户端(ssh)”。也就是说如果A机器想被B机器远程控制那么A机器需要安装SSH服务器端B机器需要安装SSH客户端。比如上图所示情况Windows系统和UbuntuB都想要访问UbuntuA那么Windiws和UbuntuB就需要安装SSH客户端而被访问的UbuntuA就需要安装SSH服务端。但通常Ubuntu系统的SSH的安装指令会同时将“服务端”和“客户端”都安装好 sudo apt-get install openssh-server演示1查看Ubuntu默认没有安装SSHD服务 下面演示Ubuntu默认没有安装SSHD服务我们不能进行远程登录。指令速览 # 1. 先安装netstat指令 lylubuntu:~/Desktop$ sudo apt install net-tools [sudo] password for lyl: Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed:net-tools 0 upgraded, 1 newly installed, 0 to remove and 578 not upgraded. Need to get 196 kB of archives. After this operation, 864 kB of additional disk space will be used. Get:1 https://mirrors.aliyun.com/ubuntu focal/main amd64 net-tools amd64 1.60git20180626.aebd88e-1ubuntu1 [196 kB] Fetched 196 kB in 0s (685 kB/s) Selecting previously unselected package net-tools. (Reading database ... 158766 files and directories currently installed.) Preparing to unpack .../net-tools_1.60git20180626.aebd88e-1ubuntu1_amd64.deb ... Unpacking net-tools (1.60git20180626.aebd88e-1ubuntu1) ... Setting up net-tools (1.60git20180626.aebd88e-1ubuntu1) ... Processing triggers for man-db (2.9.1-1) ...# 2. 查看处于LISTEN状态的端口 # 可以看到下面处于LISTEN状态的端口并没有22端口说明Ubuntu默认并没有SSHD服务监听。 lylubuntu:~/Desktop$ netstat -anp | more (Not all processes could be identified, non-owned process infowill not be shown, you would have to be root to see it all.) Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN - tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN - tcp 0 0 192.168.204.129:35502 27.22.57.186:443 TIME_WAIT - tcp6 0 0 ::1:631 :::* LISTEN - udp 0 0 0.0.0.0:60691 0.0.0.0:* - udp 0 0 0.0.0.0:5353 0.0.0.0:* - udp 0 0 127.0.0.53:53 0.0.0.0:* - udp 0 0 192.168.204.129:68 192.168.204.254:67 ESTABLISHED - udp 0 0 0.0.0.0:631 0.0.0.0:* - udp6 0 0 :::5353 :::* - 演示2Ubuntu安装SSH服务并启用 下面就需要安装SSH服务并启用指令速览 # 1. 安装SSH服务 sudo apt-get install openssh-server # 2. 启动sshd服务(会监听端口22) service sshd restart注意上面安装SSH服务的指令会在当前Linux上同时安装SSH服务端和客户端而不只是服务端(server) 下面是实际的终端演示 # 实机演示 sudo apt-get install openssh-server service sshd restart netstat -anp | more # 1. 安装SSH服务 lylubuntu:~/Desktop$ sudo apt-get install openssh-server Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed:ncurses-term openssh-client openssh-sftp-server ssh-import-id Suggested packages:keychain libpam-ssh monkeysphere ssh-askpass molly-guard The following NEW packages will be installed:ncurses-term openssh-server openssh-sftp-server ssh-import-id The following packages will be upgraded:openssh-client 1 upgraded, 4 newly installed, 0 to remove and 577 not upgraded. Need to get 1,360 kB of archives. After this operation, 6,019 kB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 https://mirrors.aliyun.com/ubuntu focal-security/main amd64 openssh-client amd64 1:8.2p1-4ubuntu0.9 [671 kB] Get:2 https://mirrors.aliyun.com/ubuntu focal-security/main amd64 ncurses-term all 6.2-0ubuntu2.1 [249 kB] Get:3 https://mirrors.aliyun.com/ubuntu focal-security/main amd64 openssh-sftp-server amd64 1:8.2p1-4ubuntu0.9 [51.7 kB] Get:4 https://mirrors.aliyun.com/ubuntu focal-security/main amd64 openssh-server amd64 1:8.2p1-4ubuntu0.9 [377 kB] Get:5 https://mirrors.aliyun.com/ubuntu focal/main amd64 ssh-import-id all 5.10-0ubuntu1 [10.0 kB] Fetched 1,360 kB in 1s (2,091 kB/s) Preconfiguring packages ... (Reading database ... 158815 files and directories currently installed.) Preparing to unpack .../openssh-client_1%3a8.2p1-4ubuntu0.9_amd64.deb ... Unpacking openssh-client (1:8.2p1-4ubuntu0.9) over (1:8.2p1-4ubuntu0.1) ... Selecting previously unselected package ncurses-term. Preparing to unpack .../ncurses-term_6.2-0ubuntu2.1_all.deb ... Unpacking ncurses-term (6.2-0ubuntu2.1) ... Selecting previously unselected package openssh-sftp-server. Preparing to unpack .../openssh-sftp-server_1%3a8.2p1-4ubuntu0.9_amd64.deb ... Unpacking openssh-sftp-server (1:8.2p1-4ubuntu0.9) ... Selecting previously unselected package openssh-server. Preparing to unpack .../openssh-server_1%3a8.2p1-4ubuntu0.9_amd64.deb ... Unpacking openssh-server (1:8.2p1-4ubuntu0.9) ... Selecting previously unselected package ssh-import-id. Preparing to unpack .../ssh-import-id_5.10-0ubuntu1_all.deb ... Unpacking ssh-import-id (5.10-0ubuntu1) ... Setting up openssh-client (1:8.2p1-4ubuntu0.9) ... Setting up ssh-import-id (5.10-0ubuntu1) ... Attempting to convert /etc/ssh/ssh_import_id Setting up ncurses-term (6.2-0ubuntu2.1) ... Setting up openssh-sftp-server (1:8.2p1-4ubuntu0.9) ... Setting up openssh-server (1:8.2p1-4ubuntu0.9) ...Creating config file /etc/ssh/sshd_config with new version Creating SSH2 RSA key; this may take some time ... 3072 SHA256:Mi2n0nliGPMjuoFm8UhtdMj49m5MyG6qUQtPidJX/k rootubuntu (RSA) Creating SSH2 ECDSA key; this may take some time ... 256 SHA256:BI4Iz6Tkl/MaqEw1rKuAsBTlKimuFJ5uWKYPbx960s rootubuntu (ECDSA) Creating SSH2 ED25519 key; this may take some time ... 256 SHA256:juRN5ixuAQ8H4zJc7ACTntHWte4r15oLtZccbY6mZU rootubuntu (ED25519) Created symlink /etc/systemd/system/sshd.service → /lib/systemd/system/ssh.service. Created symlink /etc/systemd/system/multi-user.target.wants/ssh.service → /lib/systemd/system/ssh.service. rescue-ssh.target is a disabled or a static unit, not starting it. Processing triggers for systemd (245.4-4ubuntu3.2) ... Processing triggers for man-db (2.9.1-1) ... Processing triggers for ufw (0.36-6) ...# 2. 启动sshd服务(会监听端口22) lylubuntu:~/Desktop$ service sshd restart# 3. 查看处于LISTEN状态的端口是否有22 lylubuntu:~/Desktop$ netstat -anp | more (Not all processes could be identified, non-owned process infowill not be shown, you would have to be root to see it all.) Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN - tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN - tcp 0 0 192.168.204.129:58732 27.159.77.240:443 TIME_WAIT - tcp6 0 0 ::1:631 :::* LISTEN - tcp6 0 0 :::22 :::* LISTEN # 显然这里有监听 - udp 0 0 0.0.0.0:60691 0.0.0.0:* - udp 0 0 0.0.0.0:5353 0.0.0.0:* - udp 0 0 127.0.0.53:53 0.0.0.0:* - udp 0 0 192.168.204.129:68 192.168.204.254:67 ESTABLISHED - 演示3远程登录Ubuntu 安装好SSH服务后就可以远程登录Ubuntu了共有下面两种情况 Windows远程登录UbuntuA和CentOS相同先在UbuntuA使用ifconfig查看Ubuntu的IP地址然后在Windows上使用Xshell即可远程登录UbuntuA。UbuntuB远程登录UbuntuA在创建服务器集群时会使用到该技术。UbuntuB只需开启“客户端(ssh)”无需开启“服务器端(sshd)”。基本语法如下 # 基本语法-ssh登录 ssh 用户名IP # 例ssh Ubuntu192.168.200.222 # 注若使用ssh访问出现错误,可查看是否有该文件/.ssh/known_ssh并尝试删除解决一般不会有问题。# 基本语法-ssh登出(均可) exit logout注直接复制刚建好的Ubuntu虚拟机文件夹然后就可以快速得到一个新的Ubuntu系统。但这种情况下两个主机的主机名完全相同远程登录时可以使用ifconfig查看IP地址可以发现当前登录的账户有所不同。 由于远程登录演示窗口开的有点多但原理又不复杂所以下面只给出UbuntuB远程登录UbuntuA的代码速览而没有实际的终端演示 # 1. 打开UbuntuA的终端查看UbuntuA的IP地址假设为192.168.200.222主机名为UbuntuA UbuntuA终端ifconfig# 2. 打开UbuntuB的终端查看UbuntuB的IP地址假设为192.168.200.220 UbuntuB终端ifconfig# 3. 然后远程登录到UbuntuA UbuntuB终端ssh UbuntuA192.168.200.222# 4. 再次查看IP地址发现已经变成了UbuntuA的IP证明远程登录成功 UbuntuB终端ifconfig《鸟哥的Linux私房菜 基础学习篇 第四版》 ↩︎ 《鸟哥的Linux私房菜 服务器架设篇 第三版》 ↩︎ 《韩顺平_2021图解Linux全面升级》 ↩︎
http://www.hkea.cn/news/14346051/

相关文章:

  • 二维码网站建设百度seo网站排名优化
  • 公司介绍网站怎么做的品牌建设指标考核
  • mvc网站建设设计报告电商网站建设费用价格
  • 精彩网站制作物业公司简介模板
  • 德阳移动网站建设网站 自定义表单
  • 媒体网站网页设计html前端网站开发
  • 哪家的网站效果好怎样局域网站建设
  • 网站留言如何做的在百度里面做个网站怎么做
  • 网站实用性电影海报模板哪个网站好
  • 大连建站价格手机网站模版 优帮云
  • 关键词排名推广怎么做厦门百度关键词优化
  • 网站建设模块需求分析注册一家科技公司需要多少钱
  • 网页设计与网站开发项目一般在百度做网站多少钱
  • 张家港网站制作网络推广网站空间费用
  • 网站开发的重要性深圳大型网站设计
  • 传媒公司网站源码php如何制作漂亮的微信公众号文章
  • 端午节网站建设目的旅游网站建设背景分析报告
  • 滕建建设集团网站深圳网络建设公司
  • 目前做响应式网站最好的cms怎样做网站后台运营
  • 建站公司怎么接单wordpress 接收json
  • 绍兴网站建设专业的公司4000-262-如何建立网站会员系统吗
  • 企业网站推广价格wordpress单页面网站怎么做
  • app扁平化设计网站深圳有哪些网站开发公司
  • 网站开发实训周报wordpress 数据库错误
  • ppt模板免费下载哪个网站好可以显示文章列表的wordpress主题
  • 规划建立一个网站 项目yxcms wordpress
  • 销售网站怎么做的网页设计图片与文字的研究
  • 企业网站开发需求简历表格 个人简历手机版
  • 杭州高端企业网站建设网站优化建设深圳
  • 网站优化的公司宁乡做网站地方