1.软件源
在Ubuntu下,安装软件常时,常用apt命令如下:
sudo apt-get install name
如果源里面没有找到name,则无法安装该软件。
2.源安装的原理
Ubuntu 自带了 apt的软件包管理工具,它负责 Ubuntu 系统中所有软件包的管理,包括安装、更新、卸载系统中的软件。
通过命令去安装一个软件时,apt 包管理工具就会从系统中一个源列表的文件中,查找可以包含该软件的软件源的网址,然后就从该网址把指定的软件给下载下来,并进行解压和安装。
3. 软件源的分类
- ubuntu官方软件源
- PPA软件源
PPA即为“Personal Package Archives”,个人软件包集。
很多软件无法进入官方软件库,为了能让开发者自由的上传、安装软件,launchpad.net 提供了 PPA,允许开发者建立自己的软件仓库。
添加 PPA 软件源的命令:
sudo add-apt-repository ppa:user/ppa-name
添加了之后更新一下:
sudo apt update
删除 PPA 软件源的命令:
sudo add-apt-repository --remove ppa:user/ppa-name
添加完PPA源之后,系统就会在/etc/apt/sources.list.d文件夹里创建两个文件:
其中的.list文件中保存了下载地址,以google-chrome.list为例:
也可以在软件源/etc/apt/sources.list文件中添加源,例如添加阿里云的源:
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed 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(deb-src) address section1 section2 ...