Package management#
This page considers features of package management in linux systems.
For details check:
Corresponding page in the ubuntu documentation.
In the case of this tool, the APT Wikipedia page provides a well-rounded and useful resource.
Note: Use a safe environment for running examples from this notebook, as they may change properties of your system.
Sources#
Sources in apt is a set of references that describes where to get needed packages. In the system there should be a folder /etc/apt/sources.list.d
which contains a file describing the sources.
For more check information provide by man sources.list
.
The following cell shows the default contents of /etc/apt/sources.list.d
.
ls /etc/apt/sources.list.d/
debian.sources
There is only one file called debian
. It contains some description that is not really important for us, so the following cell shows only the important content of the file. Where defines the URI for packages.
cat /etc/apt/sources.list.d/debian.sources | tail -n 15
Types: deb
# http://snapshot.debian.org/archive/debian/20250113T000000Z
URIs: http://deb.debian.org/debian
Suites: bookworm bookworm-updates
Components: main
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
Types: deb
# http://snapshot.debian.org/archive/debian-security/20250113T000000Z
URIs: http://deb.debian.org/debian-security
Suites: bookworm-security
Components: main
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
Add source#
You can add source using add-apt-repository
command.
The following cell adds the deadsnakes
source, an index where you can download different versions of the Python interpreter.
Note: add-apt-repository
is not installed by default, so it needs to be installed before use.
apt update &> /dev/null \
&& apt install -y \
software-properties-common \
python3-launchpadlib &> /dev/null
add-apt-repository -y ppa:deadsnakes/ppa &> /dev/null
Now there are additional file: /etc/apt/sources.list.d/deadsnakes-ubuntu-ppa-noble.sources
which describe the sources for deadsnake.
ls /etc/apt/sources.list.d
deadsnakes-ubuntu-ppa-bookworm.list debian.sources
The following cell shows the sources
file that was added earlier.
cat /etc/apt/sources.list.d/deadsnakes-ubuntu-ppa-bookworm.list
Logs#
/var/log/dpkg.log
is a typical path for the log which describes the packages installed on the system.
The next cell shows the default files available, which describe the default packages installed in the container.
cat /var/log/dpkg.log | tail -n 10
2025-01-25 17:58:49 configure vim:amd64 2:9.0.1378-2 <none>
2025-01-25 17:58:49 status unpacked vim:amd64 2:9.0.1378-2
2025-01-25 17:58:49 status half-configured vim:amd64 2:9.0.1378-2
2025-01-25 17:58:49 status installed vim:amd64 2:9.0.1378-2
2025-01-25 17:58:49 trigproc libc-bin:amd64 2.36-9+deb12u9 <none>
2025-01-25 17:58:49 status half-configured libc-bin:amd64 2.36-9+deb12u9
2025-01-25 17:58:49 status installed libc-bin:amd64 2.36-9+deb12u9
2025-01-25 17:58:49 trigproc hicolor-icon-theme:all 0.17-2 <none>
2025-01-25 17:58:49 status half-configured hicolor-icon-theme:all 0.17-2
2025-01-25 17:58:49 status installed hicolor-icon-theme:all 0.17-2
Now consider how the logs for the installation of a specific package look: the following cell installs vim
and displays all log entries containing vim
.
apt update &> /dev/null && apt install -y vim &> /dev/null
cat /var/log/dpkg.log | grep vim
2025-01-25 17:58:48 install vim-common:all <none> 2:9.0.1378-2
2025-01-25 17:58:48 status half-installed vim-common:all 2:9.0.1378-2
2025-01-25 17:58:48 status unpacked vim-common:all 2:9.0.1378-2
2025-01-25 17:58:48 install vim-runtime:all <none> 2:9.0.1378-2
2025-01-25 17:58:48 status half-installed vim-runtime:all 2:9.0.1378-2
2025-01-25 17:58:49 status unpacked vim-runtime:all 2:9.0.1378-2
2025-01-25 17:58:49 install vim:amd64 <none> 2:9.0.1378-2
2025-01-25 17:58:49 status half-installed vim:amd64 2:9.0.1378-2
2025-01-25 17:58:49 status unpacked vim:amd64 2:9.0.1378-2
2025-01-25 17:58:49 configure vim-common:all 2:9.0.1378-2 <none>
2025-01-25 17:58:49 status unpacked vim-common:all 2:9.0.1378-2
2025-01-25 17:58:49 status half-configured vim-common:all 2:9.0.1378-2
2025-01-25 17:58:49 status installed vim-common:all 2:9.0.1378-2
2025-01-25 17:58:49 configure vim-runtime:all 2:9.0.1378-2 <none>
2025-01-25 17:58:49 status unpacked vim-runtime:all 2:9.0.1378-2
2025-01-25 17:58:49 status half-configured vim-runtime:all 2:9.0.1378-2
2025-01-25 17:58:49 status installed vim-runtime:all 2:9.0.1378-2
2025-01-25 17:58:49 configure vim:amd64 2:9.0.1378-2 <none>
2025-01-25 17:58:49 status unpacked vim:amd64 2:9.0.1378-2
2025-01-25 17:58:49 status half-configured vim:amd64 2:9.0.1378-2
2025-01-25 17:58:49 status installed vim:amd64 2:9.0.1378-2