Linux / Tools

Dr. Torq: Basic Linux Application Management with APT

21 Dec 2019 6:00am, by

After installing a Debian or Ubuntu-based Linux distribution, it’s always a good idea to run a few commands that ensure you have the most up-to-date files and applications on your machine. If you are using one of the many desktops available you might just enlist an application manager, like synaptic to update everything.

I like to use the Linux command line for my work, so when adding a new application or upgrading something, I’ll just do it through a program called APT (“advanced package tool,” which works with Debian-styled software packages (including Ubuntu).  Red Hat has a packaging scheme called RPM and it can be managed through a program called yum. I prefer Debian-styled systems because it works the same across many hardware platforms. Xubuntu, on my ASUS notebook, as well as Raspbian Linux, for my Raspberry Pi gadgets are derivatives of Debian. The Debian-based Linux builds I use include apt as a standard package.

Today, we’ll cover how I use apt, whether setting up a Linux notebook, server or embedded computing device.

First Things First

The apt program maintains a list of installed and installable programs on your Linux device. As a habit, before installing or upgrading any programs I like to make sure the apt package listing is as current as possible. Apt, with the update option retrieves the latest software list for your particular version of Linux, checks what versions you have on your system, then renews the list on your machine. If you don’t run apt update before an apt upgrade or apt install, you might not get the latest new version of a program, an important program security patch or some specialty program, in a recently added repository. It’s pretty easy to use.

rob% sudo apt update

Apt requires system-level permission to change programs and files, so we use sudo for that purpose. Make sure you’re connected to the Internet before executing the command, otherwise not only will you not get the latest software list, you won’t be able to download any of the updated files.

apt update listing

You can always get a text summary of the apt command options using apt –help.

rob% apt --help

Upgrade

Bringing my existing software up to the latest and greatest versions goes hand-in-hand with updating the software list. That’s accomplished with the apt upgrade command.

rob% sudo apt upgrade

Apt upgrade analyses the software list on your machine, checks for dependencies, downloads new versions of applications, system programs and additional miscellaneous cruft, then proceeds to install what’s needed to bring your machine up to date. It may ask for yes/no permission to proceed. Sudo will require that you enter your regular user password and have sudo configured to allow system level access for your user name.

Apt upgrade listing

Doing an upgrade after a recent system installation may take some time and depend on a lot of different factors. For example doing an apt upgrade, for Xubuntu Linux, on my antique ASUS notebook might take five to 10 minutes. Is that unreasonable? Not really considering I’ll then have the absolute latest stable version of Linux running on a 10+-year-old machine. Doing that with anything other than Linux is likely pretty unreasonable.

A new, multicore Intel-based notebook, with tens of gigabytes of RAM, a solid-state drive and a fast internet connection should be pretty speedy. At the other end of the hardware spectrum, nano-Linux single-board computers (SBC), like the BeagleBone Black, with a gig of memory and micro SD-card based storage might take a half-hour or more to upgrade, after a new system installation.

Downloading software and replacing packages is a big, complex job. Apt is a great illustration of an automated job best performed by computers and we often take those capabilities for granted. I think it’s cool that it works great, generally without any major fuss, on so many different hardware configurations.

Let’s Install Something

The package list and software are up-to-date on our Linux box. Now, let’s install a package.

I recently wanted to try a command-line program called speedtest. I did a little online research and found out that the package was actually called speedtest-cli. The installation was straightforward.

rob% sudo apt install speedtest-cli

Adding the speedtest package with apt install

You’ll notice in the printout that apt will download about 22KB of program data and require about 100KB to install everything. Required disk space is something to keep an eye on, especially if you have limited storage available, say on a micro-SD card-based system like a Raspberry Pi. Another example might be if you are running a fairly small amount of disk space for your system files and you have a ton of packages already installed. If you don’t think the additional software will fit in the existing storage space, you might want to answer “no”, when prompted to proceed with software installation and go free up some disk space.

Searching for Packages

If you know the name of the software package, you’d like to install, just type it into apt with the search option.

rob% apt search speedtest

Looking for the speedtest package using apt search

The command above returns the listed software name, that you’d enter when installing the program. In this case, it’s speedtest-cli. The printout also shows some Linux version information and a summary description of the program function. Also notice that it indicates that the program has already been installed.

Be aware that a software package search may return several screenfuls of programs matching your search string. Searching for “LibreOffice” returned almost 350 program listings. Yes, LO is a pretty big package suite. Again, keep an eye on disk space for big packages.

Getting Rid Of Software

Sometimes, you don’t need software and want to get it off of your system. Use the remove option in apt.

rob% sudo apt remove speedtest-cli

Getting rid of the speedtest package with apt remove

That’s pretty much it for the basics. You might explore the apt command options a little more on your own.

What’s Next?

This article covered the commonly used apt options that I use in my day-to-day computing activities. The frequency order is more or less from the top down. Search and remove are only used occasionally, while update and upgrade probably happen a couple of times a week on my production Linux daily-driver notebook.

Contact Rob “drtorq” Reilly for consultation, speaking engagements and commissioned projects at doc@drtorq.com or 407-718-3274.

Feature image by FMNelly from Pixabay.

A newsletter digest of the week’s most important stories & analyses.