Monday, May 20, 2013

apt-stuff

I've become quite comfortable with using Pacman from the command line (in Bridge Linux and Chakra Linux) and equo commands for the Entropy package manager (in Sabayon), but for Debian-based distros, I tend to use Synaptic most of the time instead of apt-get from the command line. But I've found it to be useful to know how things work with either Synaptic or apt-get, and to be able to use one or the other when appropriate.

To start with, it's helpful to make use of manual pages like man apt-get, man apt-cache, man dpkg, man sources.list, and other related documents. You can open any of these man pages and scroll to the bottom to the "SEE ALSO" sections to find related man pages.

Now, I normally don't use the APT front-end aptitude, but many users prefer that over apt-get and apt-cache. There's plenty of information out there about aptitude; among other resources, there are always the man pages to refer to, and the Debian Wiki. There's also quite a bit of info in the "Maintenance and Updates: The APT Tools" section (Section 6) of The Debian Administrator's Handbook (still quite useful even though it has not yet been updated for Debian Wheezy). That's about all I'll say about aptitude here, though.

Synaptic is such a great tool that many users will have little reason to drop down to the command line for any package management tasks. For instance, if you open Synaptic and go to Settings > Preferences, on the "General" tab, next to "System upgrade:" you'll see a drop-down list that contains "Smart Upgrade," "Default Upgrade," and "Always Ask" options.



Well, "Smart Upgrade" is the same as running:

# apt-get dist upgrade

Similarly, "Default Upgrade" corresponds to apt-get upgrade. The "Reload" button at the top of Synaptic's interface is the same as apt-get update. You get the picture.

The command line tools can give you more than Synaptic in many cases, though. For example, I'm not aware of anything in Synaptic that does the same as the following command:

# apt-get clean

In fact, if you always use Synaptic, you might want to take a look at man apt-get and read about the clean, autoclean, and autoremove commands. Those can be very helpful for clearing up disk space.

Synaptic has a very nice tool under the File menu, called "History."



Synaptic's History is easy to navigate, and it'll show you all the changes you've made with Synaptic, arranged by date and time. Be aware, however, that it will NOT show you changes you've made with apt-get from the command line. For those, you'll want to take a look at the files in the /var/log/apt directory. /var/log/apt/history.log will show all the most recent package changes you've made, whether you made them with Synaptic or from the command line. The .gz files in /var/log/apt contain older history.log files.

You can compare what's shown in my Synaptic History for May 16th, above, to what's shown in my /var/log/apt/history.log for the same date:

Start-Date: 2013-05-16  09:33:08
Commandline: /usr/sbin/synaptic
Upgrade: mysql-common:i386 (5.5.30+dfsg-1.1, 5.5.31+dfsg-0+wheezy1), linux-libc-dev:i386 (3.2.41-2, 3.2.41-2+deb7u2), linux-image-3.2.0-4-686-pae:i386 (3.2.41-2, 3.2.41-2+deb7u2), libmysqlclient18:i386 (5.5.30+dfsg-1.1, 5.5.31+dfsg-0+wheezy1)
End-Date: 2013-05-16  09:33:44

Pretty much the same info.

You can really spend a lot of time learning about all the ins and outs of the various APT tools; in the end you might do like me and just use Synaptic most of the time. Or you might prefer some other GUI tool, like Ubuntu's Software Center or Kubuntu's Muon. Either way, it won't hurt to learn what you can about apt-get, apt-cache, dpkg, aptitude, etc. It's kinda fun, too.

No comments: