Managing Software - Linux Administration (2016)

Linux Administration (2016)

Managing Software

Typically, when you install software on a Linux system you do so with a package. A package is a collection of files that make up an application. Additionally, a package contains data about the application, as well as any steps required to successfully install and remove that application. The data, or metadata, that is contained within a package can include information such as the description of the application, the version of the application, and a list of other packages that it depends on. In order to install or remove a package, you need to use superuser privileges.

A package manager is used to install, upgrade, and remove packages. Any additional software that is required for a package to function properly is known as a dependency. The package manager uses a package's metadata to automatically install the dependencies. Package managers keep track of what files belong to what packages, what packages are installed, and what versions of those packages are installed.

Installing Software on CentOS, Fedora, and RedHat Distributions

Theyum command line utility is a package management program for Linux distributions that use the RPM package manager. CentOS, Fedora, Oracle Linux, RedHat Enterprise Linux, and Scientific Linux are RPM-based distributions on which you can useyum.

yum search search-string - Search for search-string.

yum install [-y] package- Install package. Use the-y option to automatically answer yes to yum's questions.

yum remove package - Remove/uninstall package.

yum info [package] - Display information about package.

To search for software to install, useyum search search-string.

$ yum search inkscape

Loaded plugins: refresh-packagekit, security

============= N/S Matched: inkscape =============

inkscape-docs.i686 : Documentation for Inkscape

inkscape.i686 : Vector-based drawing program using SVG

inkscape-view.i686 : Viewing program for SVG files

Name and summary matches only, use "search all" for everything.

$

To install software, useyum install package. Installing software requires superuser privileges. This means you need to usesudoor switch to the root account with thesu command.

$ sudo yum install inkscape

[sudo] password for bob:

Loaded plugins: refresh-packagekit, security

Setting up Install Process

Resolving Dependencies

--> Running transaction check

---> Package inkscape.i686 0:0.47-6.el6 will be installed

--> Processing Dependency: python for package:

...

Dependencies Resolved

=====================================================

Package Arch Version Repository Size

=====================================================

Installing:

inkscape i686 0.47-6.el6 base 8.6 M

Installing for dependencies:

ImageMagick i686 6.5.4.7-7.el6_5 updates 1.7 M

...

Transaction Summary

=====================================================

Install 21 Package(s)

Total download size: 21 M

Installed size: 97 M

Is this ok [y/N]: y

Downloading Packages:

(1/21): ImageMagick-6.5.4.7-7.el6_5.i686.rpm

...

Installed:

inkscape.i686 0:0.47-6.el6

Dependency Installed:

ImageMagick.i686 0:6.5.4.7-7.el6_5

...

Complete!

To uninstall a package, useyum remove. Removing software requires superuser privileges.

$ sudo yum remove inkscape

Loaded plugins: refresh-packagekit, security

Setting up Remove Process

Resolving Dependencies

--> Running transaction check

---> Package inkscape.i686 0:0.47-6.el6 will be erased

--> Finished Dependency Resolution

Dependencies Resolved

=====================================================

Package Arch Version Repository Size

=====================================================

Removing:

inkscape i686 0.47-6.el6 @base 37 M

Transaction Summary

=====================================================

Remove 1 Package(s)

Installed size: 37 M

Is this ok [y/N]: y

Downloading Packages:

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

Erasing : inkscape-0.47-6.el6.i686 1/1

Verifying : inkscape-0.47-6.el6.i686 1/1

Removed:

inkscape.i686 0:0.47-6.el6

Complete!

$

Therpm Command

In addition to theyum command, you can use the rpm command to interact with the package manager.

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/which

which-2.19-6.el6.i686

$ sudo rpm -ivh SpiderOak-5.0.3-1.i386.rpm

[sudo] password for bob:

Preparing... ####################### [100%]

1:SpiderOak ####################### [100%]

$

Installing Software on Debian and Ubuntu

The Debian and Ubuntu distributions use a package manager called APT, the Advanced Packaging Tool. APT is comprised of a few small utilities with the two most commonly used ones beingapt-cacheandapt-get.

apt-cache search search-string - Search for search-string.

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/uninstall package, leaving behind configuration files.

apt-get purge package - Remove/uninstall package, deleting configuration files.

apt-cache show package - Display information about package.

To search for software to install, useapt-cache search search-string.

$ apt-cache search inkscape

create-resources - shared resources for use by creative applications

inkscape - vector-based drawing program

python-scour - SVG scrubber and optimizer

fonts-opendin - Open DIN font

fonts-rufscript - handwriting-based font for Latin characters

ink-generator - Inkscape extension to automatically generate files from a template

lyx - document processor

robocut - Control program for Graphtec cutting plotters

sozi - inkscape extension for creating animated presentations

ttf-rufscript - handwriting-based font for Latin characters (transitional dummy package)

$

To install software, useapt-get install package. Installing software requires superuser privileges. This means you need to usesudoor switch to the root account with thesu command.

$ sudo apt-get install inkscape

Reading package lists... Done

Building dependency tree

Reading state information... Done

The following extra packages will be installed:

aspell aspell-en cmap-adobe-japan1 dbus-x11

...

3 upgraded, 74 newly installed, 0 to remove and 96 not upgraded.

Need to get 62.7 MB of archives.

After this operation, 171 MB of additional disk space will be used.

Do you want to continue [Y/n]? y

...

Setting up perlmagick (8:6.6.9.7-5ubuntu3.2) ...

Processing triggers for libc-bin ...

ldconfig deferred processing now taking place

$

To uninstall a package, useapt-get remove. Removing software requires superuser privileges.

$ sudo apt-get remove inkscape

Reading package lists... Done

Building dependency tree

Reading state information... Done

The following packages will be REMOVED:

inkscape

0 upgraded, 0 newly installed, 1 to remove and 96 not upgraded.

After this operation, 64.9 MB disk space will be freed.

Do you want to continue [Y/n]? y

(Reading database ... 69841 files and directories currently installed.)

Removing inkscape ...

Processing triggers for man-db ...

Processing triggers for hicolor-icon-theme ...

$

Thedpkg Command

In addition totheaptutilities, you can use thedpkg command to interact with the package manager.

dgpk -l - List all the installed packages.

dpkg -S /path/to/file - List the package that contains the 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 apparmor 2.7.102-0ubuntu3.9 User-space parser utility for AppArmor

ii apport 2.0.1-0ubuntu17.5 automatically generate crash reports for debugging

$ dpkg -S /usr/bin/which

debianutils: /usr/bin/which

$ sudo dpkg -i spideroak_5.1.3_i386.deb

[sudo] password for bob:

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 ...

$

Video on Installing Linux Software

If you would like to see exactly what it's like to install software on a Linux system, check out this video that I put together for you: http://www.linuxtrainingacademy.com/installing-software/

Summary

In this chapter, you learned how packages are typically used to install software on Linux systems. You learned how to manipulate packages with a package manager. Two of the most popular package formats are RPM and Debian. For RPM based distributions, you learned how to use theyum and rpm commands. For Debian based distributions you learned how to use the apt and dpkg commands to manage packages.

Resources

· Managing Software with Yum
https://www.centos.org/docs/5/html/yum/

· AptGet Howto
https://help.ubuntu.com/community/AptGet/Howto

· Ubuntu - Installing Software
https://help.ubuntu.com/community/InstallingSoftware

· Installing Linux Software Video
http://www.linuxtrainingacademy.com/installing/

Quiz

1. The Debian and RedHat Enterprise Linux distributions use the same package format.

1. True

2. False

2. How would you search for "apache" using yum?

1. yum search apache

2. yum find apache

3. yum get apache

4. yum-cache search apache

3. Which command lists all of the RPM packages installed on a system?

1. rpm -a

2. rpm -q

3. rpm -qa

4. rpm -ea

4. How would you install the htop package on a Debian based distribution?

1. apt-get htop

2. apt-get install htop

3. apt-cache install htop

4. yum-get htop

5. Which of the following commands will list the contents of the htop Debian package?

1. dpkg -S htop

2. dpkg –i htop

3. dpkg -l htop

4. dpkg –L htop


Quiz Answers

1. B

2. A

3. C

4. D