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.
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.
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.
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.
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:
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 |
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_nameHere’s an example of displaying the details of the package mysql-client:
- $ aptitude show mysql-client
- Package: mysql-client
- State: not installed
- Version: 5.5.38-0ubuntu0.14.04.1
- Priority: optional
- Section: database
- Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
- Architecture: all
- Uncompressed Size: 129 k
- Depends: mysql-client-5.5
- Provided by: mysql-client-5.5
- Description: MySQL database client (metapackage depending on the latest
- version)
- This is an empty package that depends on the current ”best” version of
- mysql-client (currently mysql-client-5.5), as determined by the MySQL
- maintainers. Install this package if in doubt about which MySQL version
- you
- want, as this is the one considered to be in the best shape by the
- Maintainers.
- Homepage: http://dev.mysql.com/
- $
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:
- $
- $dpkg -L vim-common
- /.
- /usr
- /usr/bin
- /usr/bin/xxd
- /usr/bin/helpztags
- /usr/lib
- /usr/lib/mime
- /usr/lib/mime/packages
- /usr/lib/mime/packages/vim-common
- /usr/share
- /usr/share/man
- /usr/share/man/ru
- /usr/share/man/ru/man1
- /usr/share/man/ru/man1/vim.1.gz
- /usr/share/man/ru/man1/vimdiff.1.gz
- /usr/share/man/ru/man1/xxd.1.gz
- /usr/share/man/it
- /usr/share/man/it/man1
- […]
- $
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:
- $
- $sudo aptitude install wine
- The following NEW packages will be installed:
- cabextract{a} esound-clients{a} esound-common{a} gnome-exe-thumbnailer
- {a}
- icoutils{a} imagemagick{a} libaudio2{a} libaudiofile0{a} libcdt4{a}
- libesd0{a} libgraph4{a} libgvc5{a} libilmbase6{a} libmagickcore3-extra
- {a}
- libmpg123-0{a} libnetpbm10{a} libopenal1{a} libopenexr6{a}
- libpathplan4{a} libxdot4{a} netpbm{a} ttf-mscorefonts-installer{a}
- ttf-symbol-replacement{a} winbind{a} wine wine1.2{a} wine1.2-gecko{a}
- 0 packages upgraded, 27 newly installed, 0 to remove and 0 not upgraded.
- Need to get 0B/27.6MB of archives. After unpacking 121MB will be used.
- Do you want to continue? [Y/n/?] Y
- Preconfiguring packages …
- […]
- All done, no errors.
- All fonts downloaded and installed.
- Updating fontconfig cache for /usr/share/fonts/truetype/msttcorefonts
- Setting up winbind (2:3.5.4~dfsg-1ubuntu7) …
- * Starting the Winbind daemon winbind
- [ OK ]
- Setting up wine (1.2-0ubuntu5) …
- Setting up gnome-exe-thumbnailer (0.6-0ubuntu1) …
- Processing triggers for libc-bin …
- ldconfig deferred processing now taking place
- $
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:
- $
- $ sudo aptitude safe-upgrade
- The following packages will be upgraded:
- evolution evolution-common evolution-plugins gsfonts libevolution
- xserver-xorg-video-geode
- 6 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
- Need to get 9,312kB of archives. After unpacking 0B will be used.
- Do you want to continue? [Y/n/?] Y
- Get:1 http://us.archive.ubuntu.com/ubuntu/ maverick/main
- libevolution i386 2.30.3-1ubuntu4 [2,096kB]
- […]
- Preparing to replace xserver-xorg-video-geode 2.11.9-2
- (using …/xserver-xorg-video-geode_2.11.9-3_i386.deb) …
- Unpacking replacement xserver-xorg-video-geode …
- Processing triggers for man-db …
- Processing triggers for desktop-file-utils …
- Processing triggers for python-gmenu …
- […]
- Current status: 0 updates [-6].
- $
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:
- $ sudo aptitude purge wine
- [sudo] password for user:
- The following packages will be REMOVED:
- cabextract{u} esound-clients{u} esound-common{u} gnome-exe-thumbnailer
- {u}
- icoutils{u} imagemagick{u} libaudio2{u} libaudiofile0{u} libcdt4{u}
- libesd0{u} libgraph4{u} libgvc5{u} libilmbase6{u} libmagickcore3-extra
- {u}
- libmpg123-0{u} libnetpbm10{u} libopenal1{u} libopenexr6{u}
- libpathplan4{u} libxdot4{u} netpbm{u} ttf-mscorefonts-installer{u}
- ttf-symbol-replacement{u} winbind{u} wine{p} wine1.2{u} wine1.2-gecko
- {u}
- 0 packages upgraded, 0 newly installed, 27 to remove and 6 not upgraded.
- Need to get 0B of archives. After unpacking 121MB will be freed.
- Do you want to continue? [Y/n/?] Y
- (Reading database … 120968 files and directories currently installed.)
- Removing ttf-mscorefonts-installer …
- […]
- Processing triggers for fontconfig …
- Processing triggers for ureadahead …
- Processing triggers for python-support …
- $
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:
- $ cat /etc/apt/sources.list
- #deb cdrom:[Ubuntu 14.04 LTS _Trusty Tahr_ - Release i386 (20140417)]/
- trusty main restricted
- # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
- # newer versions of the distribution.
- deb http://us.archive.ubuntu.com/ubuntu/ trusty main restricted
- deb-src http://us.archive.ubuntu.com/ubuntu/ trusty main restricted
- ## Major bug fix updates produced after the final release of the
- ## distribution.
- deb http://us.archive.ubuntu.com/ubuntu/ trusty-updates main restricted
- deb-src http://us.archive.ubuntu.com/ubuntu/ trusty-updates main restricted
- ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
- ## team. Also, please note that software in universe WILL NOT receive any
- ## review or updates from the Ubuntu security team.
- deb http://us.archive.ubuntu.com/ubuntu/ trusty universe
- deb-src http://us.archive.ubuntu.com/ubuntu/ trusty universe
- deb http://us.archive.ubuntu.com/ubuntu/ trusty-updates universe
- deb-src http://us.archive.ubuntu.com/ubuntu/ trusty-updates universe
- […]
- ## Uncomment the following two lines to add software from Canonical’s
- ## ‘partner’ repository.
- ## This software is not part of Ubuntu, but is offered by Canonical and the
- ## respective vendors as a service to Ubuntu users.
- # deb http://archive.canonical.com/ubuntu trusty partner
- # deb-src http://archive.canonical.com/ubuntu trusty partner
- ## This software is not part of Ubuntu, but is offered by third-party
- ## developers who want to ship their latest software.
- deb http://extras.ubuntu.com/ubuntu trusty main
- deb-src http://extras.ubuntu.com/ubuntu trusty main
- $
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