apt-get

<h1><a id="Header1_HeaderTitle" class="headermaintitle HeaderMainTitle" href="https://www.cnblogs.com/nagisb">NAGISB / 2024-09-26 / 原文

apt = apt-get、apt-cache 和 apt-config 中最常用命令选项的集合

1、终端里 apt-get

  1. 安装软件
sudo  apt-get install softname1 softname2softname3……
  1. 卸载软件
sudo apt-get remove softname1 softname2 softname3……
  1. 卸载并清除配置
sudo  apt-get remove --purge softname1
  1. 更新软件信息数据库
sudo apt-get update
  1. 进行系统升级
sudo apt-get upgrade
sudo apt-get distupgrade
  1. 搜索软件包
sudo apt-cache search softname1 softname2 softname3……
  1. 列出已安装包
sudo apt list --installed

2、更新apt镜像源

首先备份系统自带的源,以防修改错误!

sudo cp /etc/apt/sources.list /etc/apt/sources.list.save
  1. 列出软件信息包
apt list --upgradable
  1. 修改系统镜像源
sudo vim /etc/apt/sources.list
  1. 更新镜像源列表索引
sudo apt-get update
  1. 更新更换源后的软件版本
sudo apt-get upgrade

3、增加和删除源

  1. 修改PPA源文件
sudo ls /etc/apt/sources.list.d
  1. 增加PPA源文件
sudo add-apt-repository ppa:user/ppa-name
  1. 删除PPA源文件
sudo add-apt-repository -r ppa:user/ppa-name

4、清理cache

  1. 清理所有软件缓存
sudo apt-get clean 
  1. 清理旧版本的软件缓存
sudo apt-get autoclean
  1. 删除系统不再使用的孤立软件
sudo apt-get autoremove
  1. 安装Synaptic
sudo apt-get install synaptic

各镜像源地址:
https://mirrors.tuna.tsinghua.edu.cn/   #清华源
https://mirrors.aliyun.com/ubuntu/     #阿里云源
http://mirrors.163.com/ubuntu/   #网易源
https://mirrors.ustc.edu.cn/       #中科大源
http://repo.huaweicloud.com/      #华为源