Ubuntu包管理器APT命令

各个版本的Ubuntu更新源参考:
Ubuntu 23.04、22.04、20.04、18.04国内源–阿里云、中科大、163、清华更新源

apt update
更新本地的软件信息数据库,不会安装或者更新任何本地软件包。

apt update
[sudo] password for dev: 
Hit:1 http://mirrors.aliyun.com/ubuntu bionic InRelease
Hit:2 http://mirrors.163.com/ubuntu bionic InRelease                                          
Get:3 http://mirrors.aliyun.com/ubuntu bionic-security InRelease [88.7 kB]                    
Hit:4 http://mirrors.163.com/ubuntu bionic-security InRelease                                 
Hit:5 http://packages.microsoft.com/repos/code stable InRelease                               
Hit:6 https://download.docker.com/linux/ubuntu bionic InRelease                               
Hit:7 https://dl.google.com/linux/chrome/deb stable InRelease                                 
Hit:8 http://mirrors.163.com/ubuntu bionic-updates InRelease                                  
Hit:9 https://packages.microsoft.com/repos/edge stable InRelease                              
Get:10 http://mirrors.aliyun.com/ubuntu bionic-updates InRelease [88.7 kB]                    
Hit:11 http://mirrors.163.com/ubuntu bionic-proposed InRelease                                
Hit:12 http://mirrors.163.com/ubuntu bionic-backports InRelease                               
Hit:13 https://packages.microsoft.com/ubuntu/18.04/prod bionic InRelease                      
Get:14 http://mirrors.aliyun.com/ubuntu bionic-backports InRelease [83.3 kB]                  
Get:15 http://mirrors.aliyun.com/ubuntu bionic-proposed InRelease [242 kB]                    
Ign:16 https://www.scootersoftware.com bcompare4 InRelease                     
Hit:17 https://www.scootersoftware.com bcompare4 Release                       
Get:19 http://mirrors.aliyun.com/ubuntu bionic-security/main amd64 DEP-11 Metadata [76.8 kB]

apt upgrade [-y]
apt-get dist-upgrade 升级时自动处理依赖包,会自动安装或者升级

apt full-upgrade 会根据需要删除已经安装的软件,upgrade不会

apt install pkg1 pkg2 pkg3

apt install chromi (2次tab显示候选项或者补全,类似shell中命令自动补齐)

apt install pkg1 --no-upgrade
apt install pkg1 --only-upgrade
apt install pkg1=version

apt remove pkg1 卸载软件,保留配置文件,方便重装时恢复软件设置。大部分情况够用。
apt purge pkg1 删除软件所有数据,包括配置文件,不会修改home目录下的数据或配置
apt autoremove 自动删除已卸载软件的依赖库
apt --purge autoremove

apt search key-word
支持正则表达式

apt show pkg_name

apt depends chromium-browser
apt rdepends chromium-browser

apt download pkgname

apt list --upgradable / --installed / --all-versions

apt-cache policy chromium-browser
apt policy

$ apt policy chromium-browser
policy chromium-browser
chromium-browser:
  Installed: 111.0.5563.64-0ubuntu0.18.04.5
  Candidate: 111.0.5563.64-0ubuntu0.18.04.5
  Version table:
 *** 111.0.5563.64-0ubuntu0.18.04.5 500
        500 http://mirrors.aliyun.com/ubuntu bionic-security/universe amd64 Packages
        500 http://mirrors.aliyun.com/ubuntu bionic-updates/universe amd64 Packages
        500 http://mirrors.163.com/ubuntu bionic-security/universe amd64 Packages
        500 http://mirrors.163.com/ubuntu bionic-updates/universe amd64 Packages
        100 /var/lib/dpkg/status
     65.0.3325.181-0ubuntu1 500
        500 http://mirrors.aliyun.com/ubuntu bionic/universe amd64 Packages
        500 http://mirrors.163.com/ubuntu bionic/universe amd64 Packages

apt-mark hold pkgname 标记不自动升级
apt-mark unhold pkgname

缓存目录
/var/cache/apt/archives/

apt autoclean 清除过时软件包
apt clean 清除所有缓存

历史记录文件:
/var/log/apt/history.log

引入apt命令集就是为了解决这个问题。apt由一些来自apt-get和apt-cache且广泛使用的特性组成,同时搁置了那些令人费解且少用的特性。它也能管理apt.conf文件。

使用apt,你不必在apt-get和apt-cache命令间来回切换。apt更加的结构化,给你提供必要选项,来管理软件包。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

抓饼先生

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值