ARM & Linux 基础学习 / Ubuntu 下的包管理 / apt工具

这篇具有很好参考价值的文章主要介绍了ARM & Linux 基础学习 / Ubuntu 下的包管理 / apt工具。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

编辑整理 by Staok。

注:在 Github 上的原版文章日后可能会更新,在其它位置发的不会跟进。文章的 Gitee 仓库地址,Gitee 访问更流畅。

Ubuntu 下的包管理 / apt工具

包管理系统的功能和优点大致相同,但打包格式和工具会因平台(不同的 Linux 发行版)而异,如下表所示。

操作系统 格式 工具
Debian .deb apt, apt-cache, apt-get, dpkg
Ubuntu .deb apt, apt-cache, apt-get, dpkg
CentOS .rpm yum
Fedora .rpm dnf
FreeBSD Ports, .txz make, pkg

一般来说 Ubuntu 下很多软件是需要先自行提供源码,使用源码自行编译,编译完成以后使用命令 “install” 来安装到系统中。当然 Ubuntu 下也有其它的软件安装方法,使用得最多的方法就是自行编译源码后进行安装,尤其是嵌入式 Linux 开发。

自行对软件源码编译的一个好处是可以针对不同平台进行编译和部署。

我们利用软件包管理系统可以直接下载并安装所有通过认证的软件,其中 Ubuntu 下我们用的最多的下载工具: APT 下载工具, APT 下载工具可以实现软件自动下载、配置、安装二进制或者源码的功能。 在我们使用 APT 工具下载安装或者更新软件的时候,首先会在下载列表中与本机软件进行对比,看一下需要下载哪些软件,或者升级哪些软件,默认情况下 APT 会下载并安装最新的软件包,被安装的软件包所依赖的其它软件也会被下载安装或者更新,非常智能省心。

包管理工具 apt

Linux apt 命令 | 菜鸟教程 (runoob.com)。

# "package" 替换为 包名。
sudo apt-get update                         更新源
sudo apt-get upgrade                        更新已安装的包
sudo apt-get install package                安装包
sudo apt-get remove package                 删除包
​
sudo apt-cache search package               搜索软件包
sudo apt-cache show package                 获取包的相关信息,例如说明、大小、脚本等
​
sudo apt-get install package --reinstall    重新安装包
sudo apt-get -f install                     修复安装
sudo apt-get remove package --purge         删除包,包括配置文件等
sudo apt-get build-dep package              安装相关的编译环境
sudo apt-get dist-upgrade                   升级系统
sudo apt-cache depends package              了解使用该包依赖那些包
sudo apt-cache rdepends package             查看该包被那些包依赖
sudo apt-get source package                 下载该包的源代码
换源 和 添加系统变量

换源

Ubuntu Ports更换成阿里云镜像源-阿里云开发者社区 (aliyun.com)。

  1. 首先备份源列表:sudo cp /etc/apt/sources.list /etc/apt/sources.list_backup

  2. 编辑 /etc/apt/sources.list 文件,在文件最前面添加镜像源:

    # 阿里源
    deb https://mirrors.aliyun.com/ubuntu-ports/ xenial main restricted universe multiverse
    deb https://mirrors.aliyun.com/ubuntu-ports/ xenial-updates main restricted universe multiverse
    deb https://mirrors.aliyun.com/ubuntu-ports/ xenial-backports main restricted universe multiverse
    deb https://mirrors.aliyun.com/ubuntu-ports/ xenial-security main restricted universe multiverse
    # 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 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 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 https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security 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 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 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 main restricted universe multiverse
    deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
    deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
    deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
    deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
    ​
    # 163源
    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
  3. 更新源:

    sudo apt update
    sudo apt upgrade

添加系统变量

  • 临时:终端中键入 export PATH=$PATH:<目录/要添加的系统变量>,重启后丢失。

  • 永久(只对当前用户有效):修改 ~/.bashrc 文件,在行尾添加 export PATH=$PATH:<目录/要添加的系统变量>,然后终端键入 source ~/.bashrc 使之生效,即可。

Ubuntu 下的卸载包

Ubuntu GUI 界面操作:

  • 使用 Synaptic 软件包管理器进行卸载。系统里面若没有 Synaptic Pack Manager 软件,则在终端安装 sudo apt-get install synaptic;具体使用方法。

  • 使用 Ubuntu 的软件中心进行卸载。略。

Ubuntu 终端里操作:

  • 列出所有软件包,以可翻页的形式:dpkg --list | less;以搜索特定包名的形式:dpkg --list | grep -n "python";还可以加通配符,很灵活。

  • 卸载程序和所有配置文件:sudo apt-get --purge remove <package-name>

  • 只卸载程序但保留配置文件:sudo apt-get remove <package-name>

  • 删除没用的依赖包:sudo apt-get autoremove <package-name>,加上 --purge 选项就是程序和配置文件都删除。资源不紧张时,此条慎用。文章来源地址https://www.toymoban.com/news/detail-754767.html

到了这里,关于ARM & Linux 基础学习 / Ubuntu 下的包管理 / apt工具的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • ARM & Linux 基础学习 / 配置交叉编译工具链 / 编译 Linux 应用和驱动 / 编译内核

    编辑整理 by Staok。 本文部分内容摘自 “100ask imx6ull” 开发板的配套资料(如 百问网的《嵌入式Linux应用开发完全手册》,在 百问网 imx6ull pro 开发板 页面 中的《2.1 100ASK_IMX6ULL_PRO:开发板资料》或《2.2 全系列Linux教程:在线视频与配套资料》里面可以下载到),还有参考 菜

    2024年02月04日
    浏览(32)
  • Mac下的包管理神器,Homebrew最全入门指南

    ​ Homebrew ​ ​是一款包管理工具,目前支持 macOS ​ ​和 linux ​ ​系统。主要有四个部分组成: brew ​​、 homebrew-core ​​ 、 homebrew-cask ​​、 homebrew-bottles ​​,默认安装路径: /usr/local/Cellar/ ​​,如需修改,则修改 config ​ ​中的 HOMEBREW_PREFIX ​ ​参数(默认为 /usr/l

    2024年02月15日
    浏览(48)
  • 交叉编译工具链arm-linux-gnueabihf的安装-ubuntu 20.04

    http://t.csdn.cn/ZbjFX 建议直接在.bashrc文件作修改 ,修改方式相同 ( vi :视自己的编辑器而定) 因为我在修改profile文件后,环境变量生效,但是命令行的用户名等颜色高亮显示会消失;并且重启终端后,又需要再source一下profile。 但是将环境变量添加至.bashrc则不会出现这两个问题

    2024年02月11日
    浏览(30)
  • yum&apt安装指定版本的包

    Example: Example:

    2024年02月13日
    浏览(36)
  • 包管理器 | 浅谈几个常用的包管理工具

    目录 🖥️ 前言 ◼️ npm ◼️ cnpm ◼️ yarn ◼️ pnpm ◼️ Bower 🖥️ 参考文献  🖥️ 参考资料    如果你是前端开发者,或多或少都会接触到一些包管理工具,包管理工具是用于持续自动化程序的集合,例如安装、升级、配置和删除程序。使用包管理工具可以为前端开发解

    2024年02月13日
    浏览(247)
  • k8s的包管理工具helm

     之前的这篇文章介绍了一开始接触k8s的时候接触到的几个命令工具 kubectlkubeletrancherhelmkubeadm这几个命令行工具是什么关系?-CSDN博客 Helm 是一个用于管理和部署 Kubernetes 应用程序的包管理工具。它允许用户定义、安装和管理 Kubernetes 应用程序的模板,这些模板被称为 Charts。

    2024年01月22日
    浏览(43)
  • Linux的Ubuntu的APT使用

    apt 是 Advanced Packaging Tool 的简称,是一款安装包管理工具。在 Ubuntu 下,我们可以使用 apt 命令进行软件包的安装、删除、清理等,类似于 Windows 中的软件管理工具。 Ubuntu 软件操作的相关命令 https://mirrors.tuna.tsinghua.edu.cn/ 所谓的镜像源:可以理解为提供下载软件的地方,比如

    2024年02月22日
    浏览(25)
  • Go语言中的包管理工具之Go Modules的使用

    GoLang 中常用的包管理的方式 常用的有三种 Go Path Go Vendor Go Modules 关于 Go Modules 1 ) 概述 Go的包管理,经过社区和官方的共同努力下,最终在百家争鸣后 Go官方在 2018.8 推出了go 1.11版本中的Go Modules,并且很快成为 一统江湖的包管理方式 Go Modules已经成为目前最主流的包管理工具

    2024年02月03日
    浏览(25)
  • Go语言中的包管理工具之Go Path的使用

    GoLang 中常用的包管理的方式 1 )概述 常用的有三种 Go Path Go Vendor Go Modules 2 )发展历程 早期go的包管理存在很大缺陷,甚至可以说没有官方统一的包管理工具 一方面官方在努力发布一些实验性的包管理工具。 同时也出现了很多社区开发的包管理工具。 在官方和社区的包管理

    2024年02月03日
    浏览(29)
  • Ubuntu基础——网络配置+配置apt源(手把手教程)

    提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档       Ubuntu22.04 首先我们来到命令行输入su -( 请注意命令的空格 ),然后输入管理员密码password,进入管理员模式:    当然,Ubuntu默认管理员是没有密码的( Ubuntu的默认root密码是随机的,即每次开

    2024年02月07日
    浏览(24)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包