Apt: Difference between revisions

From DWIKI
Tony (talk | contribs)
Tag: wikieditor
Tony (talk | contribs)
 
(28 intermediate revisions by the same user not shown)
Line 2: Line 2:
Debian/Ubuntu package manager
Debian/Ubuntu package manager


 
=Documentation=
==Phased Packages==
* [https://documentation.ubuntu.com/server/explanation/software/about-apt-upgrade-and-phased-updates/index.html About apt upgrade and phased updates]
 


=Unattended upgrades=
=Unattended upgrades=
==Simple command==
==Links==
*https://help.ubuntu.com/community/AutomaticSecurityUpdates
*[https://pimylifeup.com/unattended-upgrades-debian-ubuntu/ Using Unattended-Upgrades on Debian and Ubuntu]
*https://wiki.debian.org/UnattendedUpgrades
*https://linuxblog.io/how-to-enable-unattended-upgrades-on-ubuntu-debian/
*[https://gist.github.com/CodingKoopa/3b30afe8c91e3950f6b124cd2abe3b6b the apt manpage you were looking for]
 
==Enabling/disabling unattended upgrades==
Maybe install it first
apt install unattended-upgrades
that will most likely also enable unattended upgrades
then
  dpkg-reconfigure unattended-upgrades
  dpkg-reconfigure unattended-upgrades
The dialog will show which option is selected now.


*https://help.ubuntu.com/community/AutomaticSecurityUpdates
==The relevant systemd service==
*[https://pimylifeup.com/unattended-upgrades-debian-ubuntu/ Using Unattended-Upgrades on Debian and Ubuntu]
apt-daily-upgrade.service


==Disable unattended upgrades==
==Disable unattended upgrades==
Line 18: Line 33:


==FAQ==
==FAQ==
===Unattended-upgrade is not upgrading all packages===
That's normal, it defaults to upgrading only security updates.
===Unattended-Upgrade::DevRelease "auto";===
===Unattended-Upgrade::DevRelease "auto";===
Only works on "dev releasess", which is any not .04
Only works on "dev releases", which is any not .04


==What is this Allowed-Origins about?==
==What is this Allowed-Origins about?==
Check output of
apt -s upgrade
you might see something like
Conf cloud-init (25.1.2-0ubuntu0~22.04.2 '''Ubuntu:22.04/jammy-updates'''
which will match
${distro_id}:${distro_codename}-updates
==No packages found that can be upgraded unattended==
By default '''"${distro_id}:${distro_codename}-updates";''' is commented out in '''/etc/apt/apt.conf.d/50unattended-upgrades''', so to get those updated as well, uncomment that line.


=HOWTO=
=HOWTO=
==Extract files from .deb==
==Extract files from .deb==
  dpkg-deb
  dpkg -x foo.deb ~/foo
also
mkdir tmp
dpkg-deb -R original.deb tmp


==Pin a version==
==Pin a version==
Line 33: Line 66:
==List installed packages==
==List installed packages==
  apt list --installed
  apt list --installed
==Upgrade just one package==
apt-get install --only-upgrade <packagename>
==exclude package from upgrade==
apt-mark hold somepackage
and to undo
apt-mark unhold somepackage
==Disable source in deb822 source file==
add
Enabled: no


= FAQ =
= FAQ =
==What is new style sources files called?==
deb822


== Show version of packages before installing ==
apt-get -s install somepackage
or
apt install madison-lite
apt-cache madison somepackage
or
apt-show packagename


==Show available/installed versions of package==
== the following packages have been kept back: ==
apt-cache policy elasticsearch


== have been kept back ==
Time to apt-get dist-upgrade ( but check [https://askubuntu.com/questions/194651/why-use-apt-get-upgrade-instead-of-apt-get-dist-upgrade/226213#226213 ]first But it could be different things.
See https://askubuntu.com/questions/601/the-following-packages-have-been-kept-back-why-and-how-do-i-solve-it
Perhaps:
apt-get upgrade package-that-is-kept-back
or try
apt install package-that-is-kept-back


Usually means you should run
==What version of a package is going to be installed?==
apt-cache policy <package>
==What package does a file belong to?==
dpkg -S /path/to/file


apt install <kept-back-package>
==Error messages==
or
apt upgrade packagename


otherwise
===InRelease doesn't support architecture 'i386'===
  apt dist-upgrade
set ''arch=amd64''' in sources old style or '''Architectures: amd64'' new style
 
===E: Could not get lock /var/lib/apt/lists/lock. It is held by process 1538337 (apt-get)===
 
Try
systemctl restart packagekit
and check
fuser /var/lib/apt/lists/lock
again
 
===Repository changed its 'Version' value===
Try
apt-get --allow-releaseinfo-change update
 
===The repository 'http://security.debian.org buster/updates Release' no longer has a Release file===
time to upgrade entire system


==Unable to correct problems, you have held broken packages.==
==Unable to correct problems, you have held broken packages.==
Line 100: Line 163:
  https://ppa.launchpadcontent.net/
  https://ppa.launchpadcontent.net/


===apt-key is deprecated. Manage keyring files in trusted.gpg.d instead===
See [https://itsfoss.com/apt-key-deprecated/ apt-key is deprecated]


==The following upgrades have been deferred due to phasing==
==The following upgrades have been deferred due to phasing==
Line 106: Line 172:


==needrestart==
==needrestart==
===Show which services need restarting===
needrestart -rl
===Service restarts being deferred===
===Service restarts being deferred===
Probably services like '''networkd-dispatcher.service'''.
Probably services like '''networkd-dispatcher.service'''.
Check '''/etc/needrestart/needrestart.conf''' for '''$nrconf{override_rc}'''
Check '''/etc/needrestart/needrestart.conf''' for '''$nrconf{override_rc}'''
[[Category:Debian]]

Latest revision as of 14:30, 9 June 2026

Debian/Ubuntu package manager

Documentation

Phased Packages


Unattended upgrades

Enabling/disabling unattended upgrades

Maybe install it first

apt install unattended-upgrades

that will most likely also enable unattended upgrades then

dpkg-reconfigure unattended-upgrades

The dialog will show which option is selected now.

The relevant systemd service

apt-daily-upgrade.service

Disable unattended upgrades

In /etc/apt/apt.conf.d/20auto-upgrades

APT::Periodic::Unattended-Upgrade "0";

The logs

/var/log/unattended-upgrades/*.log

FAQ

Unattended-upgrade is not upgrading all packages

That's normal, it defaults to upgrading only security updates.

Unattended-Upgrade::DevRelease "auto";

Only works on "dev releases", which is any not .04

What is this Allowed-Origins about?

Check output of

apt -s upgrade

you might see something like

Conf cloud-init (25.1.2-0ubuntu0~22.04.2 Ubuntu:22.04/jammy-updates

which will match

${distro_id}:${distro_codename}-updates

No packages found that can be upgraded unattended

By default "${distro_id}:${distro_codename}-updates"; is commented out in /etc/apt/apt.conf.d/50unattended-upgrades, so to get those updated as well, uncomment that line.

HOWTO

Extract files from .deb

dpkg -x foo.deb ~/foo

also

mkdir tmp
dpkg-deb -R original.deb tmp

Pin a version


List installed packages

apt list --installed


Upgrade just one package

apt-get install --only-upgrade <packagename>


exclude package from upgrade

apt-mark hold somepackage

and to undo

apt-mark unhold somepackage


Disable source in deb822 source file

add

Enabled: no

FAQ

What is new style sources files called?

deb822


the following packages have been kept back:

Time to apt-get dist-upgrade ( but check [1]first But it could be different things. See https://askubuntu.com/questions/601/the-following-packages-have-been-kept-back-why-and-how-do-i-solve-it Perhaps:

apt-get upgrade package-that-is-kept-back

or try

apt install package-that-is-kept-back

What version of a package is going to be installed?

apt-cache policy <package>

What package does a file belong to?

dpkg -S /path/to/file

Error messages

InRelease doesn't support architecture 'i386'

set arch=amd64 in sources old style or Architectures: amd64 new style

E: Could not get lock /var/lib/apt/lists/lock. It is held by process 1538337 (apt-get)

Try

systemctl restart packagekit

and check

fuser /var/lib/apt/lists/lock 

again

Repository changed its 'Version' value

Try

apt-get --allow-releaseinfo-change update

The repository 'http://security.debian.org buster/updates Release' no longer has a Release file

time to upgrade entire system

Unable to correct problems, you have held broken packages.

Try

dpkg --get-selections | grep hold

What packages depend on package

apt-cache rdepends --installed libc6-dev

Clear cache

apt-get clean

Could not handshake: The TLS connection was non-properly terminated.

try http instead of https

Depends: but it is not going to be installed

First try

apt-get update && apt-get upgrade

E: Unable to correct problems, you have held broken packages.

Which services should be restarted?

That's from needrestart


Prevent restarting all services when installing a package

NEEDRESTART_MODE=i apt install somepackage

What repository provides package

apt policy <packagename>

Error messages

Key is stored in legacy trusted.gpg keyring

Check apt-key is deprecated


Certificate verification failed: The certificate is NOT trusted.

try

deb [trusted=yes] ...

in sources.list, but things might be worse than that, in case of launchpad change to

https://ppa.launchpadcontent.net/


apt-key is deprecated. Manage keyring files in trusted.gpg.d instead

See apt-key is deprecated

The following upgrades have been deferred due to phasing

apt install <whatever package it lists>


needrestart

Show which services need restarting

needrestart -rl

Service restarts being deferred

Probably services like networkd-dispatcher.service. Check /etc/needrestart/needrestart.conf for $nrconf{override_rc}