This document discusses different levels of package management tools in Linux, from graphical user interfaces down to command line tools. It focuses on the command line tools YUM and RPM for RPM-based systems like Fedora, and APT and DPKG for Debian-based systems like Ubuntu. It explains how to add software repositories, update package lists, install, upgrade, and remove packages from the command line. It also discusses manually installing packages using the lowest-level RPM and DPKG tools when packages are not available in repositories.
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Installing Software, Part 2: Package Managers
1. Installing Software, Part 2
Kevin B. O'Brien
Washtenaw Linux Users Group
Washtenaw Linux Users Group 1
2. Package Tool Levels 1
GUI Package Tool
High-Level Package Tool
Low-Level Package Tool
Washtenaw Linux Users Group 2
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
Washtenaw Linux Users Group 3
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
Washtenaw Linux Users Group 4
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 shouldLinux Users need to
Washtenaw
you Group 5
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)
Washtenaw Linux Users Group 6
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/
Washtenaw Linux Users Group 7
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, type
yum install <package_name>
● Remember that all of these commands must be
run as root or using sudo
Washtenaw Linux Users Group 8
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 Washtenaw Linux Users Group 9
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 Washtenaw Linux Users Group 10
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)
Washtenaw Linux Users Group 11
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
Washtenaw Linux Users Group 12
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 – i386
baseurl=http://dl.google.com/linux/rpm/s
table/i386
enabled=1
gpgcheck=1
● http://www.google.com/linuxrepositories/
yum.html Washtenaw Linux Users Group 13
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.
Washtenaw Linux Users Group 14
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
Washtenaw Linux Users Group 15
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
Washtenaw Linux Users Group 16
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 is
yum install google-chrome
● And if you later change your mind, it is
simply
yum remove google-chrome
Washtenaw Linux Users Group 18
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)
Washtenaw Linux Users Group 19
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
Washtenaw Linux Users Group 20
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
Washtenaw Linux Users Group 21
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
Washtenaw Linux Users Group 22
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 type
yum upgrade google-chrome
Washtenaw Linux Users Group 23
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
Washtenaw Linux Users Group 24
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
Washtenaw Linux Users Group 25
26. YUM resources
● http://www.linuxpromagazine.com/Issues/2009
/103/DELICIOUS
● http://linux.die.net/man/8/yum
● http://yum.baseurl.org/
Washtenaw Linux Users Group 26
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
Washtenaw Linux Users Group 27
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 repo
deb http://http.us.debian.org/debian
stable main contrib non-free
Washtenaw Linux Users Group 28
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
Washtenaw Linux Users Group 29
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
Washtenaw Linux Users Group 30
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
Washtenaw Linux Users Group 31
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
Washtenaw Linux Users Group 32
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
Washtenaw Linux Users Group 33
34. Packages 1
● You can install packages (e.g. Google Chrome)
by
apt-get install google-chrome
● If you later change your mind, just
apt-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
Washtenaw Linux Users Group 34
35. Packages 2
● Many companies will set up repositories for
the major distros (e.g. Google)
Washtenaw Linux Users Group 35
36. More APT 1
● If you damage an install, or just think something
went wrong, you can force a reinstall
apt-get --reinstall install pine
Washtenaw Linux Users Group 36
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!
Washtenaw Linux Users Group 37
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
Washtenaw Linux Users Group 38
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
Washtenaw Linux Users Group 39
40. APT resources
● http://www.debian.org/doc/manuals/apt-howto/
Washtenaw Linux Users Group 40
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
Washtenaw Linux Users Group 41
42. Package Tool Levels
GUI Package Tool
High-Level Package Tool
Low-Level Package Tool
Washtenaw Linux Users Group 42
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
Washtenaw Linux Users Group 43
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
Washtenaw Linux Users Group 44
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.
Washtenaw Linux Users Group 45
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
Internet
rpm -i
ftp://ftp.gnomovision.com/pub/rpms/foo
bar-1.0-1.i386.rpm
Washtenaw Linux Users Group 46
47. RPM Install 4
● If you want to see some of the activity, add
a “v” option to the command
rpm -iv <package name>
● If you are the impatient kind who likes to
see progress bars, add an “h” option
rpm -ivh <package name>
Washtenaw Linux Users Group 47
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.
Washtenaw Linux Users Group 48
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 information
rpm -evv <package name>
Washtenaw Linux Users Group 49
50. RPM Upgrade
● There is an upgrade option as well
rpm -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.
Washtenaw Linux Users Group 50
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
blank
rpm -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
Washtenaw Linux Users Group 51
52. DPKG 1
● As with RPM, sometimes you can only find
a *.deb file to install from
● The commands are pretty similar
dpkg -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.
Washtenaw Linux Users Group 52
53. DPKG 2
● In DPKG you remove a package if you
don't want it any more
dpkg -r gedit
● Another option lets you remove all of the
configuration files as well
dpkg -P gedit
● Upgrading a package uses the install
command
dpkg -i gedit-2.12.2.deb
Washtenaw Linux Users Group 53
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 manager
dpkg –configure -a
● If something goes wrong in the middle of
an install, this cleans up the database
Washtenaw Linux Users Group 54
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
Washtenaw Linux Users Group 55
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”
Washtenaw Linux Users Group 56