You are hereUbuntu Tips / Finding and installing software from the command line
Finding and installing software from the command line
Introduction
One of the remarkable things about Linux is that there are many ways to do the same task. You might think why would I ever want to use the command line to install software when it's so much easier to click Applications then Ubuntu Software Centre or System then Administration then Synaptic? There are a couple of answers I can think of:
- Speed - installing from the command line is faster.
- Remote administration - if you're remotely controlling a computer it's easier to add software from the command line. This relates to speed because graphical user interfaces take longer to transmit over a session than text interfaces.
Once you know the syntax, the rest is pretty easy. The syntax isn't very difficult, and once you search and install a half-dozen times you'll remember the syntax.
I should mention here that the techniques listed below are for finding and installing software that is in what's called the Ubuntu software repositories. This means that the software is "known" and "packaged" in a way to make it easy to install under Ubuntu. Compiling software from source code (when you get a .tar.gz or .tar.bz2 file) is different from what we're talking about and will be covered soon.
Finding software (apt-cache)
The good news about finding software from the command line is that you don't need to know the software name to find it, you just have to have a general idea of what you want to find. In this example I'm going to search for software that is for configuring programs before we compile them. The syntax for searching is apt-cache search term. In this example: apt-cache search configure | more
acpid - Utilities for using ACPI power management
anacron - cron-like program that doesn't go by time
apt-listchanges - package change history notification tool
autoconf - automatic configure script builder
autoconf-doc - automatic configure script builder documentation
autoconf2.13 - automatic configure script builder (obsolete version)
autoconf2.59 - automatic configure script builder (obsolete version)
autofs - kernel-based automounter for Linux
I've actually snipped the list of software that gets displayed because it's a long list of software that contains the word configure. In this case I've added a | symbol and the word more - | more simply puts the word
You can learn more about a particular piece of software that's not installed (or is installed) by typing apt-cache show packagename. This shows a lot of details including any software dependencies (programs that get installed to install the main program you want to install). In the case of autoconf we'd type: apt-cache show autoconf
Package: autoconf
Priority: optional
Section: devel
Installed-Size: 2016
Maintainer: Ubuntu Developers
Original-Maintainer: Ben Pfaff
Architecture: all
Version: 2.64-1ubuntu1
Depends: perl (>> 5.005), m4 (>= 1.4.8), debianutils (>= 1.8)
Recommends: automake | automaken
Suggests: autoconf2.13, autobook, autoconf-archive, gnu-standards, autoconf-doc, libtool, gettext
Conflicts: autoconf2.13 (<< 2.13-47), gettext (<< 0.10.39)
Filename: pool/main/a/autoconf/autoconf_2.64-1ubuntu1_all.deb
Size: 557666
MD5sum: e5c1317cc3e539291d55b2bc31ef62e8
SHA1: c38af20ba49cf4c54ed691440ecf08452154cec4
SHA256: 3b39309e97fdf2f01317d8e0d2a4245654d79106916686c23c52381a23ca003c
Description: automatic configure script builder
The standard for FSF source packages. This is only useful if you
write your own programs or if you extensively modify other people's
programs.
.
For an extensive library of additional Autoconf macros, install the
`autoconf-archive' package. For a book that explains how to use
Autoconf, Automake, and Libtool in conjunction, install the
`autobook' package.
.
The Debian project regards the full documentation for autoconf to be
non-free, so it is not included in Debian. Nevertheless, the
non-free distribution that accompanies Debian includes the manual in
its `autoconf-doc' package.
.
This version of autoconf is not compatible with scripts meant for
Autoconf 2.13 or earlier. If you need support for such scripts,
you must also install the autoconf2.13 package.
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu >
This is a lot of information. One neat aside is you can even see where you can go to file bug reports for the software.
Installing software (apt-get install)
Installing a program where you know the package name is simple: sudo apt-get install programname. In our example we'd type: sudo apt-get install autoconf. Because we're changing the system we need to put the word sudo in front of apt-get. Sudo stands for Super User DO. Super user do this, super user do that, ... you get the idea.
Alternative ways to install (aptitude)
Normally apt-get is all that's needed to install software. Some friends I know would argue it's better to use the program aptitude because it's better at solving dependencies. Apt-get usually solves most dependency problems, but if you're having troubles you might give aptitude a try. Installing software with aptitude works in much the same way apt-get does: sudo aptitude install programname. Aptitude can also stand on it's own, it has a command line graphical interface. So if you just type sudo aptitude you'll see an interface much like the one in the screenshot at the bottom of this tutorial. I'm not sure aptitude is available in every Debian-based distribution, which is why I don't use it as much. I like to use tools I know will be available.
Conclusion
You've seen how easy it is to find and install software from the command line. You've also seen how much information you can get about a particular piece of software, whether it's installed or not. I almost forgot to mention a third reason using the command line is useful, you can combine commands for even more refined information. For example: Let's say we just want to know where we want to file bugs for the autoconf software package. If we combine our standard "grep" command with the apt-cache show command we learned above we can display only the bugs information: apt-cache show autoconf | grep Bugs
Keep learning command line commands, the more you know, the more empowered you become. It might seem a bit archaic, but command line syntax adds a whole new level of flexibility to your skills set. It's a bit like reading a book having read other books by the same author or on the same subject, you can make better comparisons and draw more thorough conclusions than just reading a single book.


