CHAPTER 14
The most common way to install software on a Linux system is through the use of packages. A package not only contains the files that are installed on the system, but also additional information called metadata. This metadata can include such information as the steps required to complete the installation in the form of pre-installation and post-installation scripts, the permission information for each of the files, the description of the package, the version, the package maintainer, and any additional packages that are required for it to function properly.
To install, upgrade, or remove packages, use a package manager. When you tell the package manager to install a given package, it not only installs that package, but also any other required packages, also called dependencies, based on the package's metadata. The package manager also maintains a database of package information. The package manager records what packages are installed, what versions are installed, and what files belong to what packages.
RPM is a recursive acronym that stands for RPM Package Manager; however, it started its life as the RedHat Package Manager. RPM-based distributions include Red Hat Enterprise Linux (RHEL), CentOS, Fedora, Oracle Linux, and Scientific Linux. You can manipulate RPM packages directly with the rpm command or with another command line utility called yum.
yum search search-pattern Search for search-pattern.
yum install [-y] package Install package. Use the -y option to automatically answer yes to yum's questions.
yum remove package Remove or uninstall package.
yum info [package] Display information about package.
To search for available software, use yum search search-pattern.
$ yum search web browser Loaded plugins: refresh-packagekit, security ======================== N/S Matched: web, browser ======================== icedtea-web.i686 : Additional Java components for OpenJDK - Java browser : plug-in and Web Start implementation elinks.i686 : A text-mode Web browser firefox.i686 : Mozilla Firefox Web browser lynx.i686 : A text-based Web browser Full name and summary matches only, use "search all" for everything. $ yum search firefox Loaded plugins: refresh-packagekit, security =========================== N/S Matched: firefox ========================== firefox.i686 : Mozilla Firefox Web browser Name and summary matches only, use "search all" for everything. $ |
To install software, use the command yum install package. Installing software requires superuser privileges. Use sudo or switch to the root account with the su command before installing or removing software.
$ sudo yum install firefox Loaded plugins: refresh-packagekit, security Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package firefox.i686 0:24.5.0-1.el6.centos will be installed --> Finished Dependency Resolution Dependencies Resolved =========================================================================== Package Arch Version Repository Size =========================================================================== Installing: firefox i686 24.5.0-1.el6.centos updates 47 M Transaction Summary =========================================================================== Install 1 Package(s) Total download size: 47 M Installed size: 80 M Is this ok [y/N]: y Downloading Packages: firefox-24.5.0-1.el6.centos.i686.rpm | 47 MB 00:14 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : firefox-24.5.0-1.el6.centos.i686 1/1 Verifying : firefox-24.5.0-1.el6.centos.i686 1/1 Installed: firefox.i686 0:24.5.0-1.el6.centos Complete! $ |
To uninstall a package, use the command yum remove package. Like installing software, removing software requires superuser privileges.
$ sudo yum remove firefox Loaded plugins: refresh-packagekit, security Setting up Remove Process Resolving Dependencies --> Running transaction check ---> Package firefox.i686 0:24.5.0-1.el6.centos will be erased --> Finished Dependency Resolution Dependencies Resolved =========================================================================== Package Arch Version Repository Size =========================================================================== Removing: firefox i686 24.5.0-1.el6.centos @updates 80 M Transaction Summary =========================================================================== Remove 1 Package(s) Installed size: 80 M Is this ok [y/N]: y Downloading Packages: Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Erasing : firefox-24.5.0-1.el6.centos.i686 1/1 Verifying : firefox-24.5.0-1.el6.centos.i686 1/1 Removed: firefox.i686 0:24.5.0-1.el6.centos Complete! $ |
You can also interact with the RPM package manager directly by using the rpm command.
rpm -qa List all the installed packages.
rpm -qf /path/to/file List the package that contains file.
rpm -ivh package.rpm Install a package from the file named package.rpm.
rpm -ql package List all files that belong to package.
$ rpm -qa | sort | head acl-2.2.49-6.el6.i686 acpid-1.0.10-2.1.el6.i686 aic94xx-firmware-30-2.el6.noarch alsa-lib-1.0.22-3.el6.i686 alsa-plugins-pulseaudio-1.0.21-3.el6.i686 alsa-utils-1.0.22-5.el6.i686 anaconda-13.21.215-1.el6.centos.i686 anaconda-yum-plugins-1.0-5.1.el6.noarch apache-tomcat-apis-0.1-1.el6.noarch apr-1.3.9-5.el6_2.i686 $ rpm -qf /usr/bin/sudo sudo-1.8.6p3-12.el6.i686 $ sudo rpm -ivh SpiderOak-5.1.3-1.i386.rpm Preparing... ####################### [100%] 1:SpiderOak ####################### [100%] $ rpm -ql sudo | head /etc/pam.d/sudo /etc/pam.d/sudo-i /etc/sudo-ldap.conf /etc/sudo.conf /etc/sudoers /etc/sudoers.d /usr/bin/sudo /usr/bin/sudoedit /usr/bin/sudoreplay /usr/libexec/sesh $ |
Linux distributions that are based on Debian use the DEB package format. Some of the more popular Debian-based distributions include Debian, Elementary OS, Linux Mint, and Ubuntu. The package manager for Debian-based distributions is called APT, the advanced packaging tool. APT is broken up into a few small commands. The two most commonly used APT commands are apt-cache and apt-get.
apt-cache search search-pattern Search for search-pattern.
apt-get install [-y] package Install package. Use the -y option to automatically answer yes to apt-get's questions.
apt-get remove package Remove or uninstall package, leaving behind configuration files.
apt-get purge package Remove or uninstall package, deleting configuration files.
apt-cache show package Display information about package.
To search for software, use the command apt-cache search search-pattern.
$ apt-cache search web browser | head abrowser - Safe and easy web browser from Mozilla - transitional package abrowser-branding - Safe and easy web browser from Mozilla - transitional package akregator - RSS/Atom feed aggregator firefox - Safe and easy web browser from Mozilla firefox-branding - Safe and easy web browser from Mozilla - transitional package firefox-dbg - Safe and easy web browser from Mozilla - debug symbols firefox-dev - Safe and easy web browser from Mozilla - development files firefox-gnome-support - Safe and easy web browser from Mozilla - GNOME support firefox-gnome-support-dbg - Safe and easy web browser from Mozilla - transitional package gimp-help-de - Documentation for the GIMP (German) $ |
To install software, use the command apt-get install package. Installing software requires superuser privileges. Use sudo or switch to the root account with the su command before installing or removing software.
$ sudo apt-get install firefox Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: libdbusmenu-gtk4 xul-ext-ubufox Suggested packages: ttf-lyx The following NEW packages will be installed: firefox libdbusmenu-gtk4 xul-ext-ubufox 0 upgraded, 3 newly installed, 0 to remove and 193 not upgraded. Need to get 36.1 MB of archives. After this operation, 82.4 MB of additional disk space will be used. Do you want to continue [Y/n]? y Get:1 http://archive.ubuntu.com/ubuntu/ precise-updates/main libdbusmenu-gtk4 amd64 0.6.2-0ubuntu0.2 [31.2 kB] Get:2 http://archive.ubuntu.com/ubuntu/ precise-updates/main firefox amd64 29.0+build1-0ubuntu0.12.04.2 [36.0 MB] Get:3 http://archive.ubuntu.com/ubuntu/ precise-updates/main xul-ext-ubufox all 2.7-0ubuntu0.12.04.1 [56.8 kB] Fetched 36.1 MB in 23s (1,535 kB/s) Selecting previously unselected package libdbusmenu-gtk4. (Reading database ... 102882 files and directories currently installed.) Unpacking libdbusmenu-gtk4 (from .../libdbusmenu-gtk4_0.6.2-0ubuntu0.2_amd64.deb) ... Selecting previously unselected package firefox. Unpacking firefox (from .../firefox_29.0+build1-0ubuntu0.12.04.2_amd64.deb) ... Selecting previously unselected package xul-ext-ubufox. Unpacking xul-ext-ubufox (from .../xul-ext-ubufox_2.7-0ubuntu0.12.04.1_all.deb) ... Processing triggers for desktop-file-utils ... Processing triggers for bamfdaemon ... Rebuilding /usr/share/applications/bamf.index... Processing triggers for gnome-menus ... Processing triggers for man-db ... Setting up libdbusmenu-gtk4 (0.6.2-0ubuntu0.2) ... Setting up firefox (29.0+build1-0ubuntu0.12.04.2) ... update-alternatives: using /usr/bin/firefox to provide /usr/bin/gnome-www-browser (gnome-www-browser) in auto mode. update-alternatives: using /usr/bin/firefox to provide /usr/bin/x-www-browser (x-www-browser) in auto mode. Please restart all running instances of firefox, or you will experience problems. Setting up xul-ext-ubufox (2.7-0ubuntu0.12.04.1) ... Processing triggers for libc-bin ... ldconfig deferred processing now taking place $ |
To uninstall a package, use the command apt-get remove package. Like installing software, removing software requires superuser privileges.
$ sudo apt-get remove firefox Reading package lists... Done Building dependency tree Reading state information... Done The following packages will be REMOVED: firefox 0 upgraded, 0 newly installed, 1 to remove and 193 not upgraded. After this operation, 81.8 MB disk space will be freed. Do you want to continue [Y/n]? y (Reading database ... 103024 files and directories currently installed.) Removing firefox ... Processing triggers for man-db ... Processing triggers for desktop-file-utils ... Processing triggers for bamfdaemon ... Rebuilding /usr/share/applications/bamf.index... Processing triggers for gnome-menus ... $ |
In addition to using the APT utilities, you can also interact directly with the package manager by using the dpkg command.
dgpk -l List all the installed packages.
dpkg –S /path/to/file List the package that contains file.
dpkg -i package.deb Install a package from the file named package.deb.
dpkg -L package List all files that belong to package.
$ dpkg -l | head Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig- pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name Version Description +++-===================-=======================-============================ ii accountsservice 0.6.15-2ubuntu9.6 query and manipulate user account information ii acpid 1:2.0.10-1ubuntu3 Advanced Configuration and Power Interface event daemon ii adduser 3.113ubuntu2 add and remove users and groups ii adium-theme-ubuntu 0.3.2-0ubuntu1 Adium message style for Ubuntu ii alsa-base 1.0.25+dfsg-0ubuntu1.1 ALSA driver configuration files $ dpkg -S /usr/bin/sudo sudo: /usr/bin/sudo $ sudo dpkg -i spideroak_5.1.3_i386.deb Selecting previously unselected package spideroak. (Reading database ... 153942 files and directories currently installed.) Unpacking spideroak (from spideroak_5.1.3_i386.deb) ... Setting up spideroak (1:5.1.3) ... Processing triggers for man-db ... Processing triggers for desktop-file-utils ... Processing triggers for bamfdaemon ... Rebuilding /usr/share/applications/bamf.index... Processing triggers for gnome-menus ... $ dpkg -L sudo | head /. /etc /etc/sudoers.d /etc/sudoers.d/README /etc/pam.d /etc/pam.d/sudo /etc/sudoers /etc/init.d /etc/init.d/sudo /usr $ |