Linux 拨号vps windows公众号手机端

ubuntu本地apt源怎么安装

lewis 6年前 (2019-09-22) 阅读数 9 #网络运维
文章标签 ubuntu

要在Ubuntu上安装本地apt源,需要执行以下步骤:

1. 在本地计算机上创建一个目录,用于存放apt源的文件。例如,可以在主目录下创建一个名为"apt-mirror"的目录。
```
mkdir ~/apt-mirror
```

2. 进入创建的目录,并创建一个名为"mirror.list"的文件,用于配置需要下载的软件包和源。
```
cd ~/apt-mirror
touch mirror.list
```

3. 编辑"mirror.list"文件,添加需要下载的软件包和源的信息。以下是一个示例:
```
deb http://archive.ubuntu.com/ubuntu bionic main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu bionic-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu bionic-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu bionic-security main restricted universe multiverse
```

4. 使用apt-mirror工具下载软件包和源文件。首先需要安装apt-mirror工具。
```
sudo apt install apt-mirror
```

5. 执行apt-mirror命令开始下载软件包和源文件。
```
sudo apt-mirror
```

6. 下载完成后,你可以在~/apt-mirror目录下看到下载的软件包和源文件。

7. 将apt源的路径配置到Ubuntu的apt源列表中。

- 打开/etc/apt/sources.list文件。
```
sudo nano /etc/apt/sources.list
```

- 在文件中添加以下内容,将路径替换为你的本地apt源的路径。
```
deb file:/home/your_username/apt-mirror bionic main restricted universe multiverse
deb file:/home/your_username/apt-mirror bionic-updates main restricted universe multiverse
deb file:/home/your_username/apt-mirror bionic-backports main restricted universe multiverse
deb file:/home/your_username/apt-mirror bionic-security main restricted universe multiverse
```

- 保存并关闭文件。

8. 更新apt源列表。
```
sudo apt update
```

现在你的系统将使用本地apt源进行软件包的安装和更新。

版权声明

本文仅代表作者观点,不代表米安网络立场。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

热门