19 Linux之Python定制篇-apt软件管理和远程登录
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默认存储的软件下载地址切换成国内的镜像源网址,就可以很方便的实现软件的安装了,如下图所示。
下面列出一些常见的镜像源地址:
- 阿里云:https://developer.aliyun.com/mirror
- 清华大学:https://mirrors.tuna.tsinghua.edu.cn/
注:更多国内的镜像源可以参考CSDN博文“国内镜像网站列表”。
吐槽:我刚安装好Ubuntu的时候,没更新源,倒霉催的啥也装不上(比如Vim)。结果按照老韩说的一步步来更新源吧,最后到复制地址到文件的时候,居!然!不!能!复!制!查了一下大概是虚拟机和Windows主机不共享剪贴板,解决了一圈没解决。我想这直接虚拟机上网复制不就好了,结果不知道为啥虚拟机又不能上网了😭。TND,我只好删除再重新安装Ubuntu虚拟机,好在可以虚拟机可以复制粘贴主机上的内容了。这一把我啥也不敢耽误,直接去更新老韩说的“清华大学镜像源”,TND的更新源的时候总是失败😭😭。最后没办法我换了阿里源,才终于更新好了😢。所以下面我演示的是更新阿里源。
打开镜像源网站后,找到Ubuntu对应的连接(网页搜索ctrl+f更快搜索),就可以找到对应的镜像地址了,如下图所示。注意一定要复制对应版本的镜像源,比如Ubuntu20.04.3就复制阿里源20.04(focal)镜像源。
现在就演示如何将/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目录
lyl@ubuntu:~/Desktop$ su root
Password:
root@ubuntu:/home/lyl/Desktop# cd /etc/apt# 2. 备份原来的镜像源地址文件
root@ubuntu:/etc/apt# ls
apt.conf.d preferences.d sources.list trusted.gpg.d
auth.conf.d sources.bak sources.list.d
root@ubuntu:/etc/apt# cp sources.list sources.list.backup
root@ubuntu:/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. 清空当前的镜像源文件
root@ubuntu:/etc/apt# echo '' > sources.list# 4. 将阿里源的内容复制到镜像源文件中
root@ubuntu:/etc/apt# vi sources.list
################################################################
# 打开后进入vi编辑器,不熟悉的同学可以百度“vi编辑器”自行了解一下。
# 使用vi是假设之前网不好,没装上vim
按i键 进入编辑模式
鼠标复制网站上的镜像源内容,然后用鼠标右键粘贴到文件中。
按下esc键
输入:wq 意为保存并退出
################################################################# 5. 告诉系统更新源
root@ubuntu:/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 64x64@2 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 64x64@2 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 64x64@2 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 64x64@2 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 64x64@2 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 64x64@2 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 64x64@2 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 64x64@2 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 64x64@2 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 64x64@2 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 64x64@2 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指令的
lyl@ubuntu:~/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
lyl@ubuntu:~/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,并验证
lyl@ubuntu:~/Desktop$ vim hello.txt
###################################
# Vim编辑器写上:hello,vim!
###################################
lyl@ubuntu:~/Desktop$ cat hello.txt
hello,vim!# 4. 还可以查看Vim的安装信息
lyl@ubuntu:~/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-discuss@lists.ubuntu.com>
Original-Maintainer: Debian Vim Maintainers <pkg-vim-maintainers@lists.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。
严格来说,使用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指令
lyl@ubuntu:~/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.60+git20180626.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.60+git20180626.aebd88e-1ubuntu1_amd64.deb ...
Unpacking net-tools (1.60+git20180626.aebd88e-1ubuntu1) ...
Setting up net-tools (1.60+git20180626.aebd88e-1ubuntu1) ...
Processing triggers for man-db (2.9.1-1) ...# 2. 查看处于LISTEN状态的端口
# 可以看到下面处于LISTEN状态的端口并没有22端口,说明Ubuntu默认并没有SSHD服务监听。
lyl@ubuntu:~/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 :::*
-
演示2:Ubuntu安装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服务
lyl@ubuntu:~/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:Mi2n0nliGPMjuoFm8UhtdM+j49m5MyG6qUQtPidJX/k root@ubuntu (RSA)
Creating SSH2 ECDSA key; this may take some time ...
256 SHA256:BI4Iz6Tkl+/MaqEw1rKuAsBTlKimuFJ5uWKYPbx960s root@ubuntu (ECDSA)
Creating SSH2 ED25519 key; this may take some time ...
256 SHA256:juRN5ixuAQ8H4zJc7ACTntHWte4r15oLtZccbY+6mZU root@ubuntu (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)
lyl@ubuntu:~/Desktop$ service sshd restart# 3. 查看处于LISTEN状态的端口是否有22
lyl@ubuntu:~/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 Ubuntu@192.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 UbuntuA@192.168.200.222# 4. 再次查看IP地址,发现已经变成了UbuntuA的IP,证明远程登录成功
UbuntuB终端:ifconfig
《鸟哥的Linux私房菜 基础学习篇 第四版》 ↩︎
《鸟哥的Linux私房菜 服务器架设篇 第三版》 ↩︎
《韩顺平_2021图解Linux全面升级》 ↩︎
相关文章:
19 Linux之Python定制篇-apt软件管理和远程登录
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韩顺…...
WebDAV之π-Disk派盘 + notototo
notototo是一款功能丰富的笔记软件,提供了多种功能,包括载入PDF文件并进行批注和标记的能力。您可以使用Apple Pencil或手指在PDF文件上进行写作和绘图操作。 同时,notototo也提供了与团队合作的功能,您可以连接到服务器并与他人协作。此外,您还可以在notototo中进行绘图,…...
_kbhit() and getch() 在小游戏中用不了。因为控制台函数,仅在控制台程序中可用
太长不看版: _kbhit() and getch() 包含在conio.h中。 conio是Console Input/Output(控制台输入输出)的简写,其中定义了通过控制台进行数据输入和数据输出的函数,主要是一些用户通过按键盘产生的对应操作,…...
dayjs格式转换成日期
目录 方法一: 编辑方法二: 这个项目在筛选订单时间的时候是由前端进行筛选的,用的是adt-design-pro进行二开的,其中在用日期组件的时候遇到了一个问题,组件返回的是: 但是我需要的是年-月-日ÿ…...
mfc140u.dll丢失如何修复?解析mfc140u.dll是什么文件跟修复方法分享
大家好!今天,我将和大家分享一下关于计算机中mfc140u.dll丢失的6种解决方法。希望我的分享能对大家在计算机使用过程中遇到问题时提供一些帮助。 首先,我想请大家了解一下什么是mfc140u.dll文件。mfc140u.dll是一个动态链接库文件࿰…...
STM32--SPI通信与W25Q64(2)
STM32–SPI通信与W25Q64(1) 文章目录 SPI外设特征 SPI框图传输模式主模式全双工连续传输 非连续传输硬件SPI读写W25Q64 SPI外设 STM32内部集成了硬件SPI收发电路,可以由硬件自动执行时钟生成、数据收发等功能,减轻CPU的负担。 特…...
微信小程序 校园周边美食商城分享系统
管理员、会员、商家可通过Android系统手机打开系统,注册登录后可进行管理员后端;首页、个人中心、会员管理、商家管理、美食类型管理、美食信息管理、美食交流、我的收藏管理、系统管理、订单管理,会员前端;首页、美食信息、美食交…...
K8S - 架构、常用K8S命令、yaml资源清单部署、Ingress、故障排查、存储卷
K8S K8S官网文档:https://kubernetes.io/zh/docs/home/学习东西还是要从官方文档入手;用于管理、扩展、自动部署容器; 其实就是 对多个跨机器的Docker集群; K8S特性 服务发现和负载均衡 Kubernetes 可以使用 DNS 名称或自己的 …...
micro benchmark 使用经验
文章目录 User Guide User Guide User Guide: https://github.com/google/benchmark/blob/main/docs/user_guide.md #include <benchmark/benchmark.h> #include <chrono> #include <thread>void BM_DemoSleep(benchmark::State& state) {for (auto _ …...
nodejs发布静态https服务器
1、先用 npm init 创建一个package.json,然后添加依赖 node-static ,package.json 如下: {"name": "freeswitch","version": "1.0.0","description": "test freeswitch for webrtc&…...
国产系统下开发QT程序总结
国产系统下开发QT程序总结 1. 国产系统简介 开发国产系统客户端的过程中,会出现兼容性问题。以下介绍Kylin和UOS环境下开发QT程序, 首先麒麟和统信这两个系统基于Ubuntu开发的。所以在Ubuntu开发理论上在国产系统上也能运行。芯片架构又分为amd,arm,mi…...
【Redis】redis入门+java操作redis
目录 一、Redis入门 1.1 Redis简介 1.2 Redis下载与安装 1.2.1 下载 1.2.2 linux安装 1.2.3 windows安装 1.3 Redis服务启动与停止 1.3.1 linux启动、停止Redis服务 1.3.2 windows启动、停止Redis服务 1.4 修改Redis启动密码 1.4.1 Linux修改设置 1.4.2 windows设…...
无涯教程-Android - Spinner函数
Spinner允许您从下拉菜单中选择一个项目 例如。使用Gmail应用程序时,将显示如下所示的下拉菜单,您需要从下拉菜单中选择一个项目。 Spinner Example 示例 本示例演示计算机的类别,您需要从类别中选择一个类别。 以下是修改后的主要Activity文件src/com.example.spinner/Andr…...
国标GB28181视频平台EasyGBS国标平台智能边缘计算网关关于小区电动车进电梯的应用方案设计
一、行业背景 随着人工智能技术的不断成熟与落地,各行各业也逐渐融入AI智能检测技术,尤其是在视频监控领域,通过AI视频智能检测与分析,可以大大提高视频的自动化、智能化监控能力。比如在小区的管理中,由电动车上楼入…...
supervisorctl(-jar)启动配置设置NACOS不同命名空间
背景 由于需要在上海服务器上面配置B测试环境,原本上面已有A测试环境,固需要将两套权限系统分开 可以使用不同的命名空间来隔离启动服务 注:本文章均不涉及公司机密 1、新建命名空间 命名空间默认会有一个public,并且不能删除&a…...
如何解决 Out Of Memory 的问题
背景 在用 Excel Importer 导入数据,当数据量超过 1w 行,经常会出现 OutOfMemory 的错误。(用 Excel Exporter 导出数据时,也会有类似问题)。 通常的表现症状如下,即在导入成功若干行之后,爆出…...
代码随想录训练营二刷第九天 | 字符串结束
总结 总体来说字符串的题目除了KMP之外难度不大,但是细节不少,有翻转的有双指针操作的。 此外一般使用双指针都是为了降低时间复杂度,从On2到On,链表除外。...
javaee spring jdbcTemplate的使用
依赖 <?xml version"1.0" encoding"UTF-8"?><project xmlns"http://maven.apache.org/POM/4.0.0" xmlns:xsi"http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation"http://maven.apache.org/POM/4.0.0 htt…...
qt day
#include "widget.h" #include "ui_widget.h" void Widget::my_slot() {} Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget) {ui->setupUi(this);this->setWindowIcon(QIcon(":/wodepeizhenshi.png"));//設置窗口的…...
Configurable Weather Parameters
1. Weather Parameters 2. Classification ClearNoon, CloudyNoon, WetNoon, WetCloudyNoon, SoftRainNoon, MidRainyNoon, HardRainNoon, ClearSunset, CloudySunset, WetSunset, WetCloudySunset, SoftRainSunset, MidRainSunset, HardRainSunset to do list: 可以关注一下…...
以下是对华为 HarmonyOS NETX 5属性动画(ArkTS)文档的结构化整理,通过层级标题、表格和代码块提升可读性:
一、属性动画概述NETX 作用:实现组件通用属性的渐变过渡效果,提升用户体验。支持属性:width、height、backgroundColor、opacity、scale、rotate、translate等。注意事项: 布局类属性(如宽高)变化时&#…...
最新SpringBoot+SpringCloud+Nacos微服务框架分享
文章目录 前言一、服务规划二、架构核心1.cloud的pom2.gateway的异常handler3.gateway的filter4、admin的pom5、admin的登录核心 三、code-helper分享总结 前言 最近有个活蛮赶的,根据Excel列的需求预估的工时直接打骨折,不要问我为什么,主要…...
聊一聊接口测试的意义有哪些?
目录 一、隔离性 & 早期测试 二、保障系统集成质量 三、验证业务逻辑的核心层 四、提升测试效率与覆盖度 五、系统稳定性的守护者 六、驱动团队协作与契约管理 七、性能与扩展性的前置评估 八、持续交付的核心支撑 接口测试的意义可以从四个维度展开,首…...
selenium学习实战【Python爬虫】
selenium学习实战【Python爬虫】 文章目录 selenium学习实战【Python爬虫】一、声明二、学习目标三、安装依赖3.1 安装selenium库3.2 安装浏览器驱动3.2.1 查看Edge版本3.2.2 驱动安装 四、代码讲解4.1 配置浏览器4.2 加载更多4.3 寻找内容4.4 完整代码 五、报告文件爬取5.1 提…...
Device Mapper 机制
Device Mapper 机制详解 Device Mapper(简称 DM)是 Linux 内核中的一套通用块设备映射框架,为 LVM、加密磁盘、RAID 等提供底层支持。本文将详细介绍 Device Mapper 的原理、实现、内核配置、常用工具、操作测试流程,并配以详细的…...
SiFli 52把Imagie图片,Font字体资源放在指定位置,编译成指定img.bin和font.bin的问题
分区配置 (ptab.json) img 属性介绍: img 属性指定分区存放的 image 名称,指定的 image 名称必须是当前工程生成的 binary 。 如果 binary 有多个文件,则以 proj_name:binary_name 格式指定文件名, proj_name 为工程 名&…...
莫兰迪高级灰总结计划简约商务通用PPT模版
莫兰迪高级灰总结计划简约商务通用PPT模版,莫兰迪调色板清新简约工作汇报PPT模版,莫兰迪时尚风极简设计PPT模版,大学生毕业论文答辩PPT模版,莫兰迪配色总结计划简约商务通用PPT模版,莫兰迪商务汇报PPT模版,…...
比较数据迁移后MySQL数据库和OceanBase数据仓库中的表
设计一个MySQL数据库和OceanBase数据仓库的表数据比较的详细程序流程,两张表是相同的结构,都有整型主键id字段,需要每次从数据库分批取得2000条数据,用于比较,比较操作的同时可以再取2000条数据,等上一次比较完成之后,开始比较,直到比较完所有的数据。比较操作需要比较…...
文件上传漏洞防御全攻略
要全面防范文件上传漏洞,需构建多层防御体系,结合技术验证、存储隔离与权限控制: 🔒 一、基础防护层 前端校验(仅辅助) 通过JavaScript限制文件后缀名(白名单)和大小,提…...
嵌入式面试常问问题
以下内容面向嵌入式/系统方向的初学者与面试备考者,全面梳理了以下几大板块,并在每个板块末尾列出常见的面试问答思路,帮助你既能夯实基础,又能应对面试挑战。 一、TCP/IP 协议 1.1 TCP/IP 五层模型概述 链路层(Link Layer) 包括网卡驱动、以太网、Wi‑Fi、PPP 等。负责…...
