Finding package versions in apt

This commit is contained in:
Kenneth John Odle 2026-08-24 09:47:22 -04:00
parent 7bd0a64ce3
commit 1e54c12a9c

View File

@ -4,13 +4,90 @@
\lettrine{S}{ometimes} you add something to your \texttt{.bashrc} file (such as a new bash alias)\index[concepts]{bash alias} and you need to reload it. Of course, this file is reloaded every time you log in, but you may not wish to log out and then log back in if you are in the middle of important work. There are few different ways to do this:
\begin{Verbatim}[]
\begin{Verbatim}[frame=single, breaklines=true]
source ~/.bashrc
\end{Verbatim}
\index{source}
and of course a shorter way:
\begin{Verbatim}[]
\begin{Verbatim}[frame=single, breaklines=true]
. ~/.bashrc
\end{Verbatim}
\end{Verbatim}
\section{To See if a Package Exists in the \texttt{apt} Repository}
\lettrine{W}{hile} there are many ways to install software on a Linux system, the easiest way is usually through the package manager, which on Ubuntu is \texttt{apt}. \index{apt} To see if a package is available in that repo, we can use
\begin{Verbatim}[frame=single, breaklines=true]
apt-cache search <package>
\end{Verbatim}
As an example, searching for the Okular document viewer in \texttt{apt} returns the following:
\begin{Verbatim}[]
libokular5core9 - libraries for the Okular document viewer
okular - universal document viewer
okular-backend-odp - Okular backend for ODP documents
okular-backend-odt - Okular backend for ODT documents
okular-dev - development files for the Okular libraries
okular-extra-backends - additional document format support for Okular
okular-mobile - mobile support for Okular
qml-module-org-kde-okular - mobile support for Okular - QML modules
\end{Verbatim}
This does not tell us which version is available however. We have a couple of options here. First, we can use
\begin{Verbatim}[frame=single, breaklines=true]
apt policy <package>
\end{Verbatim}
Using that for Okular returns the following:
\begin{Verbatim}[breaklines=true]
okular:
Installed: (none)
Candidate: 4:21.12.3-0ubuntu1
Version table:
4:21.12.3-0ubuntu1 500
500 http://us.archive.ubuntu.com/ubuntu jammy/universe amd64 Packages
100 /var/lib/dpkg/status
\end{Verbatim}
We can also use:
\begin{Verbatim}[frame=single, breaklines=true]
apt search <package>
\end{Verbatim}
Which gives a more detailed listing with the available version of all related packages:
\begin{Verbatim}[]
Sorting... Done
Full Text Search... Done
libokular5core9/jammy 4:21.12.3-0ubuntu1 amd64
libraries for the Okular document viewer
okular/jammy,now 4:21.12.3-0ubuntu1 amd64 [residual-config]
universal document viewer
okular-backend-odp/jammy 1:3.2.1+dfsg-5 amd64
Okular backend for ODP documents
okular-backend-odt/jammy 1:3.2.1+dfsg-5 amd64
Okular backend for ODT documents
okular-dev/jammy 4:21.12.3-0ubuntu1 amd64
development files for the Okular libraries
okular-extra-backends/jammy 4:21.12.3-0ubuntu1 amd64
additional document format support for Okular
okular-mobile/jammy 4:21.12.3-0ubuntu1 amd64
mobile support for Okular
qml-module-org-kde-okular/jammy 4:21.12.3-0ubuntu1 amd64
mobile support for Okular - QML modules
\end{Verbatim}
\ktcbox{I generally prefer to install software from the \texttt{apt} repository, but sometimes it does not have the most recent version. These tools allow me to quickly check which version the repo does have. If the version is acceptable, I can install from there, or if not, I can explore other options.}