Added «apt list» and examples.

This commit is contained in:
Kenneth John Odle 2026-08-24 16:42:36 -04:00
parent 21357a2932
commit a289380560

View File

@ -20,7 +20,7 @@ and of course a shorter way:
\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 \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] \begin{Verbatim}[frame=single, breaklines=true]
apt-cache search <package> apt search <package>
\end{Verbatim} \end{Verbatim}
As an example, searching for the Okular document viewer in \texttt{apt} returns the following: As an example, searching for the Okular document viewer in \texttt{apt} returns the following:
@ -140,4 +140,47 @@ Description: universal document viewer
\end{Verbatim} \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.} \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.}
\section{To See Which Packages Have Been Installed}
\lettrine{I}{nstalling} software is easy on a Linux-based system. The problem is that sometimes you forget what you've installed. There are a few ways to do this. The first is
\begin{Verbatim}[frame=single]
apt list --installed
\end{Verbatim}
This will give output like this:
\begin{Verbatim}[breaklines=true]
Listing... Done
abcm2ps/jammy,now 8.14.11-0.1 amd64 [installed]
accountsservice/jammy-security,jammy-updates,now 22.07.5-2ubuntu1.6 amd64 [installed,automatic]
acl/jammy,now 2.3.1-1 amd64 [installed,automatic]
acpi-support/jammy,now 0.144 amd64 [installed,automatic]
acpid/jammy,now 1:2.0.33-1ubuntu1 amd64 [installed,automatic]
adduser/jammy,jammy,now 3.118ubuntu5 all [installed,automatic]
adwaita-icon-theme-full/jammy,jammy,now 41.0-1ubuntu1 all [installed,automatic]
adwaita-icon-theme/jammy,jammy,now 41.0-1ubuntu1 all [installed,automatic]
adwaita-qt/jammy,now 1.4.1-1 amd64 [installed,automatic]
aglfn/jammy,jammy,now 1.7+git20191031.4036a9c-2 all [installed,automatic]
aisleriot/jammy,now 1:3.22.22-1 amd64 [installed,automatic]
alsa-base/jammy,jammy,now 1.0.25+dfsg-0ubuntu7 all [installed,automatic]
[…snip]
\end{Verbatim}
Unfortunately, that will give you a list of \texttt{every} packaged that has been installed on your system, including from when you installed Linux originally. To get a list of manually installed applications, use
\begin{Verbatim}[frame=lines]
apt list --manually-installed
\end{Verbatim}
On my system, using the \texttt{--installed} option produced 3,184 lines of output, whereas using the \texttt{--manual-installed} option produced 237 lines of output—a considerable difference.
If necessary, you can redirect this information to a file using
\begin{Verbatim}[frame=lines]
apt list --installed > app_list.txt
\end{Verbatim}
Which will produce a warning: ``\texttt{WARNING: apt does not have a stable CLI interface. Use with caution in scripts.}'' What that means is that the \texttt{apt} command is meant to be used in an interactive mode (it includes things like progress bars when downloading and installing software, for example) and its output is not really able to be parsed in a script. (These commands work fine, however, as the output has a simple structure.) For scripting purposes, you really want to use \texttt{apt-get} and \texttt{apt-cache}.