ubuntu - 1.常用命令 - apt

Publish Data: 2025-3-9

APT(Advanced Packaging Tool)是Ubuntu操作系统中的一个强大的包管理系统,用于安装、更新和卸载软件包。它不仅简化了软件包的管理过程,还提高了安装过程的可靠性和效率。

APT与APT-GET的关系

APT命令实际上是apt-get、apt-cache和apt-config中最常用命令选项的集合。从Ubuntu 16.04开始,官方建议使用APT代替apt-get,因为APT提供了更全面的工具和更好的用户体验

其配置文件位于 /etc/apt/目录中

 1 tianjh@ubtdlts2024:~$ cd /etc/apt/
 2 tianjh@ubtdlts2024:/etc/apt$ ll
 3 总计 52
 4 drwxr-xr-x   9 root root  4096 Dec 20 20:52 ./
 5 drwxr-xr-x 144 root root 12288 Mar  9 21:16 ../
 6 drwxr-xr-x   2 root root  4096 Feb 18 18:21 apt.conf.d/
 7 drwxr-xr-x   2 root root  4096 Apr  1  2024 auth.conf.d/
 8 drwxr-xr-x   2 root root  4096 Apr  1  2024 keyrings/
 9 drwxr-xr-x   2 root root  4096 Feb 18 18:21 preferences.d/
10 drwxr-xr-x   2 root root  4096 Apr 24  2024 preferences.d.save/
11 -rw-r--r--   1 root root    70 Dec 20 20:54 sources.list
12 drwxr-xr-x   2 root root  4096 Feb 18 18:21 sources.list.d/
13 -rw-r--r--   1 root root    70 Dec 20 20:54 sources.list.save
14 drwxr-xr-x   2 root root  4096 Feb 18 18:21 trusted.gpg.d/

apt 常用命令

#升级系统中已安装的所有软件
apt upgrade

#获取最新的软件包列表
apt update

#搜索软件包
apt search {pkgname}

#安装软件包
apt install {pkgname}

#卸载不需要的软件包
apt remove {pkgname}

#查询依赖其它软件包的命令
apt-cache depends {pkgname}

#查看哪些软件依赖当前软件包的命令
apt-cache rdepends {pkgname}

#查看软件包来源于哪个仓库
#apt-cache madison {pkgname}

#锁定版本
apt-mark hold {pkgname}

#解锁
apt-mark unhold {pkgname}


 

posted @ 2025-03-09 22:00  lightway  阅读(130)  评论(0)    收藏  举报