zoukankan      html  css  js  c++  java
  • ubuntu中aptget install 改用阿里云作为数据源

    首先可以将系统中的数据源的源列表文件备份一下。

    sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

    然后编辑源列表文件内容

    sudo vim /etc/apt/sources.list

    将里面的内容改为阿里云即可,以下是用Ubuntu16.04为例子。16.04对应的代称是xenial。如果其他版本,可以将代称修改。

    deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse

    ubuntu的源最好也加上,避免某些库找不到。

    deb http://archive.ubuntu.com/ubuntu/ xenial main restricted universe multiverse
    deb http://archive.ubuntu.com/ubuntu/ xenial-security main restricted universe multiverse
    deb http://archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe multiverse
    deb http://archive.ubuntu.com/ubuntu/ xenial-proposed main restricted universe multiverse
    deb http://archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse

    运行sudo apt-get update

    运行sudo apt-get upgrade

    apt-get 工作原理
    Ubuntu采用集中式的软件仓库机制,将各式各样的软件包分门别类地存放在软件仓库中,进行有效地组织和管理。然后,将软件仓库置于许许多多的镜像服务器中,并保持基本一致。这样,所有的Ubuntu用户随时都能获得最新版本的安装软件包。因此,对于用户,这些镜像服务器就是他们的软件源(Reposity)

    然而,由于每位用户所处的网络环境不同,不可能随意地访问各镜像站点。为了能够有选择地访问,在Ubuntu系统中,使用软件源配置文件/etc/apt/sources.list列出最合适访问的镜像站点地址。

    1. apt-get的更新过程
    1)执行apt-get update
    2)程序分析/etc/apt/sources.list
    3)自动连网寻找list中对应的Packages/Sources/Release列表文件,如果有更新则下载之,存入/var/lib/apt/lists/目录
    4)然后 apt-get install 相应的包 ,下载并安装。

    即使这样,软件源配置文件只是告知Ubuntu系统可以访问的镜像站点地址,但那些镜像站点具体都拥有什么软件资源并不清楚。若每安装一个软件包,就在服务器上寻找一遍,效率是很低的。因而,就有必要为这些软件资源列个清单(建立索引文件),以便本地主机查询。

    用户可以使用“apt-get update”命令刷新软件源,建立更新软件包列表。在Ubuntu Linux中,“apt-get update”命令会扫描每一个软件源服务器,并为该服务器所具有软件包资源建立索引文件,存放在本地的/var/lib/apt/lists/目录中。 使用apt-get执行安装、更新操作时,都将依据这些索引文件,向软件源服务器申请资源。因此,在计算机设备空闲时,经常使用“apt-get update”命令刷新软件源,是一个好的习惯。

    2. apt-get install 原理

    3. apt-get 常用操作

    apt-cache search packagename 搜索包
    apt-cache show packagename 获取包的相关信息,如说明、大小、版本等
    apt-get install packagename 安装包
    apt-get install packagename - - reinstall 重新安装包
    apt-get -f install 修复安装"-f = --fix-missing"
    apt-get remove packagename 删除包
    apt-get remove packagename - - purge 删除包,包括删除配置文件等
    apt-get update 更新源
    apt-get upgrade 更新已安装的包
    apt-get dist-upgrade 升级系统
    apt-get dselect-upgrade 使用 dselect 升级
    apt-cache depends packagename 了解使用依赖
    apt-cache rdepends packagename 是查看该包被哪些包依赖
    apt-get build-dep packagename 安装相关的编译环境
    apt-get source packagename 下载该包的源代码
    apt-get clean 清理无用的包
    apt-get autoclean 清理无用的包
    apt-get check 检查是否有损坏的依赖

     #阿里源
         deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
         deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
         deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
         deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
         deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
         deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
         deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
         deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
         deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
         deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
    
        #网易源
        deb http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
         deb http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
         deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
         deb http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
         deb http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
         deb-src http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
         deb-src http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
         deb-src http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
         deb-src http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
         deb-src http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
    
        #清华源
        deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
         deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
         deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
         deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
         deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
         deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
         deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
         deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
         deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
         deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
    
        ##中科大源
        deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
         deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
         deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
         deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
         deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
         deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
         deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
         deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
         deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
         deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
    
    天道酬勤 循序渐进 技压群雄
  • 相关阅读:
    20165301结对编程项目-四则运算 (第二周)
    20165301第八周课下作业
    20165301 2017-2018-2 《Java程序设计》第八周学习总结
    20165301实验二java面向对象程序设计
    20165301结对编程项目-四则运算 (第一周)
    2018-2019-1 20165306 《信息安全系统设计基础》第三周学习总结
    2018-2019-1 20165306《信息安全系统设计基础》第一周学习总结
    20165306 2017-2018-2《Java程序设计》课程总结
    2017-2018-2 20165306 实验五《网络编程与安全》实验报告
    2017-2018-2 20165306 实验四《Android开发基础》实验报告
  • 原文地址:https://www.cnblogs.com/wuyuan2011woaini/p/15748433.html
Copyright © 2011-2022 走看看