-->

Installing Software On Linux Using Debian packages

In the old days of Linux, installing software could be a painful experience. Fortunately, the Linux developers have made life a little easier for us by bundling software into pre-built packages that are much easier to install. However, you still have a little work to do to get the software packages installed, especially if you want to do that from the command line. This chapter looks at the various Package Management Systems available in Linux and the command line tools used for software installation, management, and removal.

Installing Software On Linux Using Debian packages
Installing Software On Linux Using Debian packages

Package Management Primer

Before diving into the world of Linux software package management, this chapter goes through a few of the basics first. Each of the major Linux distributions utilizes some form of a Package Management System (PMS) to control installing software applications and libraries. A PMS utilizes a database that keeps track of these items:

What software packages are installed on the Linux system What files have been installed for each package Versions of each of the software packages installed Software packages are stored on servers, called repositories, and are accessed across the Internet via PMS utilities running on your local Linux system. You can use the PMS utilities to search for new software packages or even updates to software packages already installed on the system.

A software package often has dependencies or other packages that must be installed first for the software to run properly. The PMS utilities detect these dependencies and offer to install any additionally needed software packages before installing the desired package.

The downside to PMS is that there isn’t a single standard utility. Whereas all the bash shell commands discussed so far in this book work no matter which Linux distribution you use, this is not true with software package management.

The PMS utilities and their associated commands are vastly different between the various Linux distributions. The two primary PMS base utilities commonly used in the Linux world are dpkg and rpm.

Debian-based distributions such as Ubuntu and Linux Mint use, at the base of their PMS utilities, the dpkg command. This command interacts directly with the PMS on the Linux system and is used for installing, managing, and removing software packages.

The Red Hat–based distributions, such as Fedora, openSUSE, and Mandriva, use the rpm command at the base of their PMS. Similar to the dpkg command, the rpm command can list installed packages, install new packages, and remove existing software.

Note that these two commands are the core of their respective PMS, not the entire PMS itself. Many Linux distributions that use the dpkg or rpm methods have built additional specialty PMS utilities upon these base commands to help make your life much easier. The following sections walk through various PMS utility commands you’ll run into in the popular Linux distributions.

The Debian-Based Systems

The dpkg command is at the core of the Debian-based family of PMS tools. These other tools are included in this PMS:

  • apt-get
  • apt-cache
  • aptitude

By far the most common command line tool is aptitude, and for good reason. The aptitude tool is essentially a front-end for both the apt tools and dpkg. Whereas dpkg is a PMS tool, aptitude is a complete Package Management System.

Using the aptitude command at the command line helps you avoid common software installation problems, such as missing software dependencies, unstable system environments, and just a whole lot of unnecessary hassle. This section looks at how to use the aptitude command tool from the Linux command line.

Managing packages with aptitude

A common task faced by Linux system administrators is to determine what packages are already installed on the system. Fortunately, aptitude has a handy interactive interface that makes this task an easy one.

If you have aptitude installed in your Linux distribution, at the shell prompt just type aptitude and press Enter. You are thrown into aptitude’s full-screen mode.

The aptitude main window
The aptitude main window

Use the arrow keys to maneuver around the menu. Select the menu option Installed Packages to see what packages are installed. You will see several groups of software packages, such as editors, and so on. A number in parentheses follows each group, which indicates the number of packages the group contains.

Use the arrow keys to highlight a group, and press Enter to see each subgroup of packages. You then see the individual package names and their version numbers. Press Enter on individual packages to get very detailed information, such as the package’s description, home page, size, maintainer, and so on.

When you’re finished viewing the installed packages, press q to quit the display. You can then go back to the arrow keys. and use Enter to toggle open or closed the packages and their subgroups. When you are all finished, just press q multiple times until you receive the pop-up screen “Really quit Aptitude?”

If you already know the packages on your system and want to quickly display detailed information about a particular package, you don’t need to go into aptitude’s interactive interface. You can use aptitude as a single command at the command line:
aptitude show package_name
Here’s an example of displaying the details of the package mysql-client:

  1. $ aptitude show mysql-client
  2. Package: mysql-client
  3. State: not installed
  4. Version: 5.5.38-0ubuntu0.14.04.1
  5. Priority: optional
  6. Section: database
  7. Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
  8. Architecture: all
  9. Uncompressed Size: 129 k
  10. Depends: mysql-client-5.5
  11. Provided by: mysql-client-5.5
  12. Description: MySQL database client (metapackage depending on the latest
  13. version)
  14. This is an empty package that depends on the current ”best” version of
  15. mysql-client (currently mysql-client-5.5), as determined by the MySQL
  16. maintainers. Install this package if in doubt about which MySQL version
  17. you
  18. want, as this is the one considered to be in the best shape by the
  19. Maintainers.
  20. Homepage: http://dev.mysql.com/
  21. $


Note
The aptitude show command indicates that the package is not installed on the system. It also shows detailed package information from the software repository. 

One detail you cannot get with aptitude is a listing of all the files associated with a particular software package. To get this list, you must go to the dpkg tool itself:
dpkg -L package_name
Here’s an example of using dpkg to list all the files installed as part of the vim-common package:

  1. $
  2. $dpkg -L vim-common
  3. /.
  4. /usr
  5. /usr/bin
  6. /usr/bin/xxd
  7. /usr/bin/helpztags
  8. /usr/lib
  9. /usr/lib/mime
  10. /usr/lib/mime/packages
  11. /usr/lib/mime/packages/vim-common
  12. /usr/share
  13. /usr/share/man
  14. /usr/share/man/ru
  15. /usr/share/man/ru/man1
  16. /usr/share/man/ru/man1/vim.1.gz
  17. /usr/share/man/ru/man1/vimdiff.1.gz
  18. /usr/share/man/ru/man1/xxd.1.gz
  19. /usr/share/man/it
  20. /usr/share/man/it/man1
  21. […]
  22. $


You can also do the reverse — find what package a particular file belongs to:
dpkg —search absolute_file_name
Note that you need to use an absolute file reference for this to work:
$$dpkg —search /usr/bin/xxdvim-common: /usr/bin/xxd$
The output shows the /usr/bin/xxd file was installed as part of the vim-common package.

Installing software packages with aptitude

Now that you know more about listing software package information on your system, this section walks through a software package install. First, you’ll want to determine the package name to install. How do you find a particular software package? Use the aptitude command with the search option:
aptitude search package_name
The beauty of the search option is that you do not need to insert wildcards around package_name. Wildcards are implied. Here’s an example of using aptitude to look for the wine software package:


Notice that before each package name is either a p or i. If you see an i u, the package is currently installed on your system. If you see a p or v, it is available but not installed. As you can see from the preceding listing, this system does not have wine currently installed, but the package is available from the software repository.

Installing a software package on a system from a repository using aptitude is as easy as this:
aptitude install package_name
After you find the software package name from the search option, just plug it into the aptitude command using the install option:

  1. $
  2. $sudo aptitude install wine
  3. The following NEW packages will be installed:
  4. cabextract{a} esound-clients{a} esound-common{a} gnome-exe-thumbnailer
  5. {a}
  6. icoutils{a} imagemagick{a} libaudio2{a} libaudiofile0{a} libcdt4{a}
  7. libesd0{a} libgraph4{a} libgvc5{a} libilmbase6{a} libmagickcore3-extra
  8. {a}
  9. libmpg123-0{a} libnetpbm10{a} libopenal1{a} libopenexr6{a}
  10. libpathplan4{a} libxdot4{a} netpbm{a} ttf-mscorefonts-installer{a}
  11. ttf-symbol-replacement{a} winbind{a} wine wine1.2{a} wine1.2-gecko{a}
  12. 0 packages upgraded, 27 newly installed, 0 to remove and 0 not upgraded.
  13. Need to get 0B/27.6MB of archives. After unpacking 121MB will be used.
  14. Do you want to continue? [Y/n/?] Y
  15. Preconfiguring packages …
  16. […]
  17. All done, no errors.
  18. All fonts downloaded and installed.
  19. Updating fontconfig cache for /usr/share/fonts/truetype/msttcorefonts
  20. Setting up winbind (2:3.5.4~dfsg-1ubuntu7) …
  21. * Starting the Winbind daemon winbind
  22. [ OK ]
  23. Setting up wine (1.2-0ubuntu5) …
  24. Setting up gnome-exe-thumbnailer (0.6-0ubuntu1) …
  25. Processing triggers for libc-bin …
  26. ldconfig deferred processing now taking place
  27. $


Note
Before the aptitude command in the preceding listing, the sudo command is used. The sudo command allows you to run a command as the root user. You can use the sudo command to run administrative tasks, such as installing software.

To check if the installation processed properly, just use the search option again. This time you should see an i u listed in front of the wine software package, indicating it is installed.

You may also notice that there are additional packages with the i u in front of them. This is because aptitude automatically resolved any necessary package dependencies for us and installs the needed additional library and software packages. This is a wonderful feature included in many Package Management Systems.

Updating software with aptitude

While aptitude helps protect you from problems installing software, trying to coordinate a multiple-package update with dependencies can get tricky. To safely update all the software packages on a system with any new versions in the repository, use the safeupgrade option:
aptitude safe-upgrade
Notice that this command doesn’t take a software package name as an argument. That’s because the safe-upgrade option upgrades all the installed packages to the most recent version available in the repository, which is safer for system stabilization.

Here’s a sample output from running the aptitude safe-update command:

  1. $
  2. $ sudo aptitude safe-upgrade
  3. The following packages will be upgraded:
  4. evolution evolution-common evolution-plugins gsfonts libevolution
  5. xserver-xorg-video-geode
  6. 6 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
  7. Need to get 9,312kB of archives. After unpacking 0B will be used.
  8. Do you want to continue? [Y/n/?] Y
  9. Get:1 http://us.archive.ubuntu.com/ubuntu/ maverick/main
  10. libevolution i386 2.30.3-1ubuntu4 [2,096kB]
  11. […]
  12. Preparing to replace xserver-xorg-video-geode 2.11.9-2
  13. (using …/xserver-xorg-video-geode_2.11.9-3_i386.deb) …
  14. Unpacking replacement xserver-xorg-video-geode …
  15. Processing triggers for man-db …
  16. Processing triggers for desktop-file-utils …
  17. Processing triggers for python-gmenu …
  18. […]
  19. Current status: 0 updates [-6].
  20. $


You can also use less-conservative options for software upgrades:
aptitude full-upgradeaptitude dist-upgrade
These options perform the same task, upgrading all the software packages to the latest versions. Where they differ from safe-upgrade is that they do not check dependencies between packages. The whole package dependency issue can get real ugly. If you’re not exactly sure of the dependencies for the various packages, stick with the safe-upgrade option.

Note
Obviously, running aptitude’s safe-upgrade option is something you should do on a regular basis to keep your system up to date. However, it is especially important to run it after a fresh distribution installation. Usually, lots of security patches and updates have been released since the last full release of a distribution.

Uninstalling software with aptitude

Getting rid of software packages with aptitude is as easy as installing and upgrading them. The only real choice you have to make is whether to keep the software’s data and configuration files around afterward.

To remove a software package, but not the data and configuration files, use the remove option of aptitude. To remove a software package and the related data and configuration files, use the purge option:

  1. $ sudo aptitude purge wine
  2. [sudo] password for user:
  3. The following packages will be REMOVED:
  4. cabextract{u} esound-clients{u} esound-common{u} gnome-exe-thumbnailer
  5. {u}
  6. icoutils{u} imagemagick{u} libaudio2{u} libaudiofile0{u} libcdt4{u}
  7. libesd0{u} libgraph4{u} libgvc5{u} libilmbase6{u} libmagickcore3-extra
  8. {u}
  9. libmpg123-0{u} libnetpbm10{u} libopenal1{u} libopenexr6{u}
  10. libpathplan4{u} libxdot4{u} netpbm{u} ttf-mscorefonts-installer{u}
  11. ttf-symbol-replacement{u} winbind{u} wine{p} wine1.2{u} wine1.2-gecko
  12. {u}
  13. 0 packages upgraded, 0 newly installed, 27 to remove and 6 not upgraded.
  14. Need to get 0B of archives. After unpacking 121MB will be freed.
  15. Do you want to continue? [Y/n/?] Y
  16. (Reading database … 120968 files and directories currently installed.)
  17. Removing ttf-mscorefonts-installer …
  18. […]
  19. Processing triggers for fontconfig …
  20. Processing triggers for ureadahead …
  21. Processing triggers for python-support …
  22. $


To see if the package has been removed, you can use the aptitude search option again.

If you see a c in front of the package name, it means the software has been removed, but the configuration files have not been purged from the system. A p in front indicates the configuration files have also been removed.

The aptitude repositories

The default software repository locations for aptitude are set up for you when you install your Linux distribution. The repository locations are stored in the file /etc/apt/sources.list.

In many cases, you never need to add/remove a software repository so you don’t need to touch this file. However, aptitude pulls software from only these repositories. Also, when searching for software to install or update, aptitude checks only these repositories. If you need to include some additional software repositories for your PMS, this is the place to do it.

Tip
The Linux distribution developers work hard to make sure package versions added to the repositories don’t conflict with one another. Usually it’s safest to upgrade or install a software package from the repository. Even if a newer version is available elsewhere, you may want to hold off installing it until that version is available in your Linux distribution’s repository

The following is an example of a sources.list file from an Ubuntu system:

  1. $ cat /etc/apt/sources.list
  2. #deb cdrom:[Ubuntu 14.04 LTS _Trusty Tahr_ - Release i386 (20140417)]/
  3. trusty main restricted
  4. # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
  5. # newer versions of the distribution.
  6. deb http://us.archive.ubuntu.com/ubuntu/ trusty main restricted
  7. deb-src http://us.archive.ubuntu.com/ubuntu/ trusty main restricted
  8. ## Major bug fix updates produced after the final release of the
  9. ## distribution.
  10. deb http://us.archive.ubuntu.com/ubuntu/ trusty-updates main restricted
  11. deb-src http://us.archive.ubuntu.com/ubuntu/ trusty-updates main restricted
  12. ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
  13. ## team. Also, please note that software in universe WILL NOT receive any
  14. ## review or updates from the Ubuntu security team.
  15. deb http://us.archive.ubuntu.com/ubuntu/ trusty universe
  16. deb-src http://us.archive.ubuntu.com/ubuntu/ trusty universe
  17. deb http://us.archive.ubuntu.com/ubuntu/ trusty-updates universe
  18. deb-src http://us.archive.ubuntu.com/ubuntu/ trusty-updates universe
  19. […]
  20. ## Uncomment the following two lines to add software from Canonical’s
  21. ## ‘partner’ repository.
  22. ## This software is not part of Ubuntu, but is offered by Canonical and the
  23. ## respective vendors as a service to Ubuntu users.
  24. # deb http://archive.canonical.com/ubuntu trusty partner
  25. # deb-src http://archive.canonical.com/ubuntu trusty partner
  26. ## This software is not part of Ubuntu, but is offered by third-party
  27. ## developers who want to ship their latest software.
  28. deb http://extras.ubuntu.com/ubuntu trusty main
  29. deb-src http://extras.ubuntu.com/ubuntu trusty main
  30. $


First, notice that the file is full of helpful comments and warnings. The repository sources specified use the following structure:

deb (or deb-src) address distribution_name package_type_list
The deb or deb-src value indicates the software package type. The deb value indicates it is a source of compiled programs, whereas the deb-src value indicates it is a source of source code.

The address entry is the software repository’s web address. The distribution_name entry is the name of this particular software repository’s distribution’s version. In the example, the distribution name is trusty. This does not necessarily mean that the distribution you are running is Ubuntu’s Trusty Tahr; it just means the Linux distribution is using the Ubuntu Trusty Tahr software repositories! For example, in Linux Mint’s sources.list file, you see a mix of Linux Mint and Ubuntu software repositories.

Finally, the package_type_list entry may be more than one word and indicates what type of packages the repository has in it. For example, you may see values such as main, restricted, universe, or partner.

When you need to add a software repository to your sources file, you can try to wing it yourself, but that more than likely will cause problems. Often, software repository sites or various package developer sites have an exact line of text that you can copy from their website and paste into your sources.list file. It’s best to choose the safer route and just copy/paste.

The front-end interface, aptitude, provides intelligent command line options for working with the Debian-based dpkg utility. Now it’s time to look at the Red Hat–based distributions’ rpm utility and its various front-end interfaces.


0 Response to "Installing Software On Linux Using Debian packages"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel