1. 应用场景
- 当我们需要在多台电脑安装同一个软件,并且这个软件很大,下载需要很长时间;
- 需要安装软件的ubuntu系统不能上网;
2. 制作流程
- 操作系统版本为:18.04.1-Ubuntu
- ubuntu源地址配置文件存储路径为:/etc/apt/sources.list
- 安装包默认存储路径为:/var/cache/apt/archives
在可以上网的ubuntu系统中将需要离线安装的包下载下来,由于默认ubuntu系统的源下载安装包较慢,将源更新为阿里云的源
sudo vi /etc/apt/sources.list
内容如下:
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted deb http://mirrors.aliyun.com/ubuntu/ bionic universe deb http://mirrors.aliyun.com/ubuntu/ bionic-updates universe deb http://mirrors.aliyun.com/ubuntu/ bionic multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-updates multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted deb http://mirrors.aliyun.com/ubuntu/ bionic-security universe deb http://mirrors.aliyun.com/ubuntu/ bionic-security multiverse
通过如下指令下载XXXX软件所需要的deb包,以openssh-server为例:
sudo apt-get -y install openssh-server
执行完上述指令后,openssh-server安装完毕并且安装包已下载至默认存储目录。
3. 离线安装
将offlinePackage.tar.gz复制到根目录下,解压
sudo tar zxvf offlinePackage.tar.gz -C /
添加之前可以先将原来的源备份
sudo cp /etc/apt/sources.list /etc/apt/sources.list.back
将安装包所在和源路径添加到系统源文件中,内容如下:
deb [trusted=yes] file:/// offlinePackage/
注意:
若搭建局域网内部源,则配置文件内容应修改如下:
deb [trusted=yes] http://192.168.91.128 /
sudo apt-get update
输出如下:
获取:1 file: offlinePackage/ InRelease 忽略:1 file: offlinePackage/ InRelease 获取:2 file: offlinePackage/ Release 忽略:2 file: offlinePackage/ Release 获取:3 file: offlinePackage/ Packages 忽略:3 file: offlinePackage/ Packages 获取:4 file: offlinePackage/ Translation-en 忽略:4 file: offlinePackage/ Translation-en 获取:5 file: offlinePackage/ Translation-zh 忽略:5 file: offlinePackage/ Translation-zh 获取:6 file: offlinePackage/ Translation-zh_CN 忽略:6 file: offlinePackage/ Translation-zh_CN 获取:3 file: offlinePackage/ Packages 忽略:3 file: offlinePackage/ Packages 获取:4 file: offlinePackage/ Translation-en 忽略:4 file: offlinePackage/ Translation-en 获取:5 file: offlinePackage/ Translation-zh 忽略:5 file: offlinePackage/ Translation-zh 获取:6 file: offlinePackage/ Translation-zh_CN 忽略:6 file: offlinePackage/ Translation-zh_CN 获取:3 file: offlinePackage/ Packages 忽略:3 file: offlinePackage/ Packages 获取:4 file: offlinePackage/ Translation-en 忽略:4 file: offlinePackage/ Translation-en 获取:5 file: offlinePackage/ Translation-zh 忽略:5 file: offlinePackage/ Translation-zh 获取:6 file: offlinePackage/ Translation-zh_CN 忽略:6 file: offlinePackage/ Translation-zh_CN 获取:3 file: offlinePackage/ Packages [11.0 kB] 获取:4 file: offlinePackage/ Translation-en 忽略:4 file: offlinePackage/ Translation-en 获取:5 file: offlinePackage/ Translation-zh 忽略:5 file: offlinePackage/ Translation-zh 获取:6 file: offlinePackage/ Translation-zh_CN 忽略:6 file: offlinePackage/ Translation-zh_CN 获取:4 file: offlinePackage/ Translation-en 忽略:4 file: offlinePackage/ Translation-en 获取:5 file: offlinePackage/ Translation-zh 忽略:5 file: offlinePackage/ Translation-zh 获取:6 file: offlinePackage/ Translation-zh_CN 忽略:6 file: offlinePackage/ Translation-zh_CN 获取:4 file: offlinePackage/ Translation-en 忽略:4 file: offlinePackage/ Translation-en 获取:5 file: offlinePackage/ Translation-zh 忽略:5 file: offlinePackage/ Translation-zh 获取:6 file: offlinePackage/ Translation-zh_CN 忽略:6 file: offlinePackage/ Translation-zh_CN 获取:4 file: offlinePackage/ Translation-en 忽略:4 file: offlinePackage/ Translation-en 获取:5 file: offlinePackage/ Translation-zh 忽略:5 file: offlinePackage/ Translation-zh 获取:6 file: offlinePackage/ Translation-zh_CN 忽略:6 file: offlinePackage/ Translation-zh_CN 正在读取软件包列表... 完成
sudo apt-get -y install openssh-server --allow-unauthenticated
注意:一定要带上–allow-unauthenticated参数!
原文链接:https://blog.csdn.net/siguoyi/article/details/118551337
© 版权声明
声明📢本站内容均来自互联网,归原创作者所有,如有侵权必删除。
本站文章皆由CC-4.0协议发布,如无来源则为原创,转载请注明出处。
THE END