56
Washtenaw Linux Users Group 1 Installing Software, Part 2 Kevin B. O'Brien Washtenaw Linux Users Group

Installing Software, Part 2: Package Managers

Embed Size (px)

DESCRIPTION

This second presentation in the series looks at the package managers available for downloading and installing Linux software

Citation preview

Page 1: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 1

Installing Software, Part 2

Kevin B. O'BrienWashtenaw Linux Users Group

Page 2: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 2

Package Tool Levels 1

GUI Package Tool

High-Level Package Tool

Low-Level Package Tool

Page 3: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 3

Package Tool Level 2

● For newcomers, the easiest level to work at is the GUI Package Tool

● That is what we looked at in the first presentation

● But a GUI is just a front-end for what you can do on the command line

● The command line is much more powerful

Page 4: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 4

Package Tool Level 3

● Anything you can do with a GUI you can do on a command line

● But the command line will let you do more than the GUI will

● When the GUI has trouble with a package install you will generally need to use the command line to fix the problem

● These are all administrative tasks, so run them as root or use sudo

Page 5: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 5

Two flavors

● While we looked at three GUI tools in the previous presentation, here we will only look at two sets of command line tools

● They are YUM (and RPM) and APT (and DPKG)

● They work with RPM and Debian packages respectively

● There are others, but once you learn the basic principles you can pick up the others pretty easily should you need to

Page 6: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 6

RPM

● RPM stands for Red Hat Package Manager● Red Hat is the major distro for corporate

and server center environments● Many major distros have adopted RPM as

well: OpenSUSE, Mandriva, etc.● RPM can be run by itself from the

command line, or you can use an intermediate tool like YUM (Yellowdog Updater, Modified)

Page 7: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 7

YUM 1

“Yum is an automatic updater and package installer/remover for rpm systems. It automatically computes dependencies and figures out what things should occur to install packages. It makes it easier to maintain groups of machines without having to manually update each one using rpm.”

http://yum.baseurl.org/

Page 8: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 8

YUM 2● Although there are GUI front-ends for YUM, we

will focus on the command line use (PackageKit, which we covered in the first presentation, is the default for Fedora since version 9)

● YUM is pretty simple● To install a program, typeyum install <package_name>

● Remember that all of these commands must be run as root or using sudo

Page 9: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 9

YUM 3

● What happens when you enter this command?

● YUM checks the database of packages available in the repositories it knows about

● If it finds the package, it then checks the headers of the package to discover any dependencies

● It then prepares to download and install all of the files needed to get your package up and running

Page 10: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 10

It's Not There?● What if you get an error that there is no such

package?● That means that it is not in any of the

repositories that your system knows about● Do a Google search (or Bing, if you really must)

to find the repository. Many companies maintain repos for the major two systems (e.g. Google)

● If that does not work, you may need to resort to more drastic measures, covered in a future presentation

Page 11: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 11

Repositories

● We covered this in some detail in the previous presentation

● These are online collections of software packages that you can download and install

● You will have the best results using repositories that are designed for your distro

● These can be created by the distro itself, or by third-parties (e.g. Miro)

Page 12: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 12

Repositories 2

● Adding a repository is easiest with the GUI front-ends because they do so much of it for you

● But you can add one if you know how to use a text editor

Page 13: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 13

Adding a repo 1● Example, adding Google's Linux repo● As root, add the following to a file called google.repo in /etc/yum.repos.d/:

[google]name=Google – i386baseurl=http://dl.google.com/linux/rpm/stable/i386enabled=1gpgcheck=1

● http://www.google.com/linuxrepositories/yum.html

Page 14: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 14

Adding a repo 2

● So, you first need to be able to run a text editor as root (or by using sudo)

● Then you need to create a file in a specified directory (/etc/yum.repos.d/)

● The file needs to have a name that identifies it, and an extension of *.repo. You can pick the name you want to use, but it should be descriptive enough that you can find it if needed.

Page 15: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 15

Adding a repo 3

● Finally, you have to enter some structured information into this text file

● The last line, gpgcheck=1, will cause it to automatically download and add a GPG signature while you are installing it

Page 16: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 16

Adding a Repo 4

● To check, try adding the Google repo as shown above

● Then open PackageKit, and update your package lists

● Then run a search for “google”● You will see lots of available packages● Then check your Software Sources, and

see it listed

Page 17: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 17

Adding a Repo 5

Page 18: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 18

YUM 4

● So, with the new Google repository added, let's say you wanted to install the new Google browser, Chrome, all you do isyum install google-chrome

● And if you later change your mind, it is simplyyum remove google-chrome

Page 19: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 19

Updating Repositories● You want to keep your information on what is in

the repos up-to-date● You can get a manual update any time by

entering yum update

● To automate this more, edit the file /etc/yum/yum-updatesd.conf (Note: This file may not exist at first, so you would need to create it with a text editor)

Page 20: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 20

yum-updatesd.conf 1

● This is the configuration file for yum-updatesd

● Instructions can be found at http://linux.die.net/man/5/yum-updatesd.conf

● You can set the interval to check the repos here

Page 21: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 21

yum-updatesd.conf 2

● You can set it to notify you in several ways; probably e-mail will be the easiest.

● You could set it to install updates automatically, or to just download them automatically

Page 22: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 22

YUM upgrades 1

● Generally speaking, update means to check the info on what the latest versions are of your packages

● It is only informational● Upgrade means to actually download and

install the newest version

Page 23: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 23

YUM upgrades 2

● So, if you learned (through an update) there was a new version of Google Chrome that you wanted to install you would typeyum upgrade google-chrome

Page 24: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 24

YUM process summarized 1

● You can add repos to your collection● You can then update the info in them to

make sure it is current, and set this up to happen automatically in yum-updatesd.conf

● You can upgrade packages● You can install new packages

Page 25: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 25

YUM process summarized 2

● You can remove ones you don't need any more

● And all of this can be done at the command line

Page 26: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 26

YUM resources

● http://www.linuxpromagazine.com/Issues/2009/103/DELICIOUS

● http://linux.die.net/man/8/yum● http://yum.baseurl.org/

Page 27: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 27

APT, the Debian way

● The other major package management system is APT (Advanced Package Tool), which is used in Debian and related distros (Ubuntu being a major one here)

● This works a lot like yum, which is not surprising since they are doing the same things

Page 28: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 28

Repositories

● Just as with YUM, you need to maintain your repository information when using APT

● This is kept in a file /etc/apt/sources.list

● Here, each repo has a line in this single file● For example, here is the main Debian repodeb http://http.us.debian.org/debian stable main contrib non-free

Page 29: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 29

Repository lines 1● The first entry “deb”, says that is a repo

containing binary packages for Debian● If they contained source code, the first item

would be “deb-src”● In either case, this is followed by the address of

the repo. These are most often http, but can also be ftp, ssh, or point to a local file

Page 30: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 30

Repository Lines 2

● This is followed by the name of the distribution; in Debian is might be “stable”, in Ubuntu it might be “jaunty”.

● The remaining fields are optional, but add some more description

Page 31: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 31

Managing Repositories 1● Adding a repo is as simple as adding a line

to /etc/apt/sources.list

● As root, or using sudo, use a text editor to add a line to the list to add a repository

● To remove one, you can just delete the line, but it is easier and safer to just comment out the line by putting “# “ in front of the line (pound sign and a space)

● To re-enable the repo, just remove the comment

Page 32: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 32

Managing Repositories 2

● As with YUM, you want to keep everything up-to-date

● APT keeps information about the contents of each repository, and about what packages you have installed, in a local database

Page 33: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 33

Managing Repositories 3

● You can update the information about each repo with apt-get update

● Remember, this is an administrative task, so either run as root or use sudo for all commands

Page 34: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 34

Packages 1

● You can install packages (e.g. Google Chrome) by apt-get install google-chrome

● If you later change your mind, justapt-get remove google-chrome

● As with YUM, if you get an error that the package could not be found, you should do a search to see if there is a repository that contains it

Page 35: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 35

Packages 2

● Many companies will set up repositories for the major distros (e.g. Google)

Page 36: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 36

More APT 1● If you damage an install, or just think something

went wrong, you can force a reinstallapt-get --reinstall install pine

Page 37: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 37

More APT 2

● You can also upgrade your packages

– Always do an update first to make sure you have the latest information

– Then apt-get -u upgrade

– The “-u” switch causes the command to display a list of all of the packages that will be upgraded. You wouldn't do this blind!

Page 38: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 38

APT and Upgrades● If you run this upgrade, sometimes it will tell

you that some packages were not upgraded, that the upgrades were “held back”. This can be due to breaking a dependency, or because of a new dependency

● For new dependencies, you can install the needed packages

● You can also use APT to find out which packages have upgrades available:apt-show-versions -u

Page 39: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 39

Distribution Upgrades

● If you have a completely new distribution version (common with Ubuntu, for instance, which releases new versions every 6 months)apt-get -u dist-upgrade

Page 40: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 40

APT resources

● http://www.debian.org/doc/manuals/apt-howto/

Page 41: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 41

The Lowest Level

● Recall that there are three levels in package management

● Our first presentation focused on GUI front ends

● This presentation has so far focused on the middle level, using the command line

● There is also the lowest level

Page 42: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 42

Package Tool Levels

GUI Package Tool

High-Level Package Tool

Low-Level Package Tool

Page 43: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 43

RPM and DPKG

● For our two package management systems, the lowest levels are RPM (Red Hat Package Manager) and DPKG (Debian package)

● These are most often used when there is a package available, but it is not in a repository

● For example, a web site may offer a package with an extension *.rpm or *.deb

Page 44: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 44

RPM Install 1● For example, suppose you needed to install

Cinelarra for a 64-bit system, and you don't have it in a repository

● But you find this:cinelerra-2.1-0.15.20081102.fc9.x86_64.rpm

● This is an RPM package, which you can install

rpm -i cinelerra-2.1-0.15.20081102.fc9.x86_64.rpm

Page 45: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 45

RPM Install 2● This command invokes RPM, tells it to install

(-i), and gives it the name of the package to install

● This is still package management. RPM is doing a bunch of things as part of the installation process

– Performing dependency checks.

– Checking for conflicts.

– Performing any tasks required before the install.

– Deciding what to do with config files.

Page 46: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 46

RPM Install 3– Unpacking files from the package and putting

them in the proper place.

– Performing any tasks required after the install.

– Keeping track of what it did. (i.e. updating the database)

● RPM can also perform an install over the Internetrpm -i ftp://ftp.gnomovision.com/pub/rpms/foobar-1.0-1.i386.rpm

Page 47: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 47

RPM Install 4

● If you want to see some of the activity, add a “v” option to the commandrpm -iv <package name>

● If you are the impatient kind who likes to see progress bars, add an “h” optionrpm -ivh <package name>

Page 48: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 48

RPM Erase 1● In RPM, removing a package is called “erase”rpm -e <package name>

● Again, this is doing a lot more than simply deleting a couple of files

– It checks the RPM database to make sure that no other packages depend on the package being erased.

– It executes a pre-uninstall script (if one exists).

– It checks to see if any of the package's config files have been modified. If so, it saves copies of them.

Page 49: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 49

RPM Erase 2– It reviews the RPM database to find every file

listed as being part of the package, and if they do not belong to another package, deletes them.

– It executes a post-uninstall script (if one exists).

– It removes all traces of the package (and the files belonging to it) from the RPM database.

● There is no “v” option for the erase command, but there is a variation called “vv” that gives you a lot of informationrpm -evv <package name>

Page 50: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 50

RPM Upgrade

● There is an upgrade option as wellrpm -U <package name>

● Note the capital “U” here● Essentially, what this command does

is a combination of install and erase. It installs the new version and erases the old version, all in one go.

Page 51: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 51

RPM Upgrade Remorse

● Suppose you upgraded a package you really love to the newest version

● You try to run it, and your screen goes blankrpm -Uv --oldpackage <package name>

● This is like “upgrading” to the older version● Note: If you can boot to a command prompt

you can do this

Page 52: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 52

DPKG 1

● As with RPM, sometimes you can only find a *.deb file to install from

● The commands are pretty similardpkg -i gedit-2.12.1.deb

● As with RPM, the DPKG package manager is doing a lot in the background

– It is checking and resolving dependencies

– It is installing any other packages needed

– It is updating the database, etc.

Page 53: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 53

DPKG 2

● In DPKG you remove a package if you don't want it any moredpkg -r gedit

● Another option lets you remove all of the configuration files as welldpkg -P gedit

● Upgrading a package uses the install commanddpkg -i gedit-2.12.2.deb

Page 54: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 54

DPKG 3

● One of my favorites is a command to use to help clean up a problem that has come up when I tried to use a more high-level package managerdpkg –configure -a

● If something goes wrong in the middle of an install, this cleans up the database

Page 55: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 55

Resources

● RPM– http://www.faqs.org/docs/securing/chap3sec20.

html

– http://www.rpm.org/max-rpm-snapshot/

● DPKG– http://linuxhelp.blogspot.com/2005/12/concise-

apt-get-dpkg-primer-for-new.html

– http://www.cyberciti.biz/howto/question/linux/dpkg-cheat-sheet.php

Page 56: Installing Software, Part 2: Package Managers

Washtenaw Linux Users Group 56

Final Thoughts

● The four package managers we covered in this presentation (YUM, RPM, APT, DPKG) all have a lot more capabilities than this one presentation could cover. Check the man pages for a full description of what they can do.

● One more time, remember that all of these commands are administrative commands, and you need to run them as root, or precede them with “sudo”