APT(Advanced Package Tool) 是 Linux 系统中用于管理软件包的核心工具,主要用于 Debian 及其衍生发行版(如 Ubuntu、Linux Mint 等)。它提供了软件包的安装、更新、卸载和依赖管理功能,简化了系统软件的维护。
安装软件包
sudo apt install <包名>
更新软件包列表
sudo apt update
/etc/apt/sources.list
)同步最新的软件包信息(不实际升级软件)。升级已安装的软件
sudo apt upgrade
sudo apt full-upgrade
可处理依赖冲突(可能删除旧包)。卸载软件包
sudo apt remove <包名> # 卸载但保留配置文件
sudo apt purge <包名> # 彻底卸载(包括配置文件)
搜索软件包
apt search <关键词> # 搜索可用软件包
apt show <包名> # 显示软件包详细信息
清理无用文件
sudo apt autoremove # 删除自动安装的、不再需要的依赖包
sudo apt clean # 清理下载的软件包缓存(`/var/cache/apt/archives/`)
/etc/apt/sources.list
或 /etc/apt/sources.list.d/
管理软件源(支持 HTTP、FTP、本地路径等)。dpkg
(处理 .deb
包)和 apt-get
/apt-cache
等命令。apt-get
apt
类似,但 apt
更友好)。sudo apt-get install <包名>
apt-cache
apt-cache search <关键词>
)。aptitude
软件源错误
/etc/apt/sources.list
或使用 sudo add-apt-repository
添加正确的源。依赖冲突
sudo apt --fix-broken install
或 sudo apt full-upgrade
。缓存问题
bash
sudo apt clean
sudo apt update
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install ./google-chrome-stable_current_amd64.deb
APT 是 Debian 系 Linux 的高效包管理工具,掌握它能极大提升系统管理效率。遇到问题时,可通过 man apt
查看手册或使用 apt --help
获取帮助。