apt 与 apt-get

  • APT: Advanced Packaging Tool
  • apt 命令不是 apt-get 的简写
  • apt 整合了 apt-get、apt-cache 和 apt-config 中的常用命令
  • 可以将 apt 看作 apt-get 的升级版
  • 常用命令对比

    apt 命令示例取代的命令命令的功能
    apt installapt install unzipapt-get install安装软件包
    apt removeapt remove unzipapt-get remove移除软件包
    apt purgeapt purge unzipapt-get purge移除软件包及配置文件
    apt dependsapt depends python3apt-cache depends查看软件包依赖
    apt updateapt updateapt-get update刷新存储库索引
    apt upgradeapt upgradeapt-get upgrade升级所有可升级的软件包
    apt autoremoveapt autoremoveapt-get autoremove自动删除不需要的包
    apt full-upgradeapt full-upgradeapt-get dist-upgrade在升级软件包时自动处理依赖关系
    apt searchapt search unzipapt-cache search在 package descriptions 搜索
    apt showapt show unzipapt-cache show显示 package 的详细情况
    apt listapt list "*unzip"根据 package 名字列出 package
    apt list --installedapt list --installed查看已安装的 package
    apt edit-sourcesapt edit-sources编辑源列表

软件仓库

位置免费/收费维护方
main免费Ubuntu官方维护
universe免费社区维护
restricted收费第三方维护(一般是品牌厂商)
multiverse收费野库
  • 可以用命令查看某个 package 属于 Main,Universe,Restricted 还是 Multiverse。

    apt policy <package>
  • 也可以在 launchpad 查看

更新等级

  • UbuntuUpdates

    security:重要的安全更新
    updates:非安全性更新,即不影响到系统安全的 bug 修补。
    proposed:预更新,小 beta 版,过后会进入[updates]或[security]。
    backports:新软件的反向导出,新软件为老系统编译的版本。

软件源

以 Ubuntu 20.04 为例

中科大

  • /etc/apt/sources.list 生成器: repository file generator
  • 替换 sources.list 的命令

    # http 源
    wget https://mirrors.ustc.edu.cn/repogen/conf/ubuntu-http-4-focal -O sources.list
    # or https 源
    wget https://mirrors.ustc.edu.cn/repogen/conf/ubuntu-https-4-focal -O sources.list
    sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak
    sudo mv sources.list /etc/apt/sources.list
    sudo apt update

阿里云

  • 阿里云 Ubuntu 镜像
  • 编辑文件 /etc/apt/sources.list

    sudo apt edit-sources
  • Ubuntu 20.04 LTS(x86)

    deb https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
    deb-src https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
    
    deb https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
    deb-src https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
    
    deb https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
    deb-src https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
    
    deb https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
    deb-src https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
    
    ## Not recommended
    # deb https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
    # deb-src https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
  • Ubuntu 20.04 LTS(arm)

    deb https://mirrors.aliyun.com/ubuntu-ports/ focal main restricted universe multiverse
    deb-src https://mirrors.aliyun.com/ubuntu-ports/ focal main restricted universe multiverse
    
    deb https://mirrors.aliyun.com/ubuntu-ports/ focal-security main restricted universe multiverse
    deb-src https://mirrors.aliyun.com/ubuntu-ports/ focal-security main restricted universe multiverse
    
    deb https://mirrors.aliyun.com/ubuntu-ports/ focal-updates main restricted universe multiverse
    deb-src https://mirrors.aliyun.com/ubuntu-ports/ focal-updates main restricted universe multiverse
    
    deb https://mirrors.aliyun.com/ubuntu-ports/ focal-backports main restricted universe multiverse
    deb-src https://mirrors.aliyun.com/ubuntu-ports/ focal-backports main restricted universe multiverse
    
    ## Not recommended
    # deb https://mirrors.aliyun.com/ubuntu-ports/ focal-proposed main restricted universe multiverse
    # deb-src https://mirrors.aliyun.com/ubuntu-ports/ focal-proposed main restricted universe multiverse
本文出自 qbit snap

qbit
268 声望279 粉丝