温馨提示×

ubuntu本地apt源怎么安装

小亿
205
2023-10-12 17:02:31
栏目: 智能运维

要在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源进行软件包的安装和更新。

0