Episode 8 Package managers
In this episode, we explore some of the capabilities of package managers for installing and updating software on your system. Specifically, we look at the ‘apt’ system on Ubuntu GNU/Linux. On other systems, you might use Yum (RedHat/Fedora), Pacman (Arch), or Homebrew (Mac). This page shows a comparison of commands for several Linux packaging systems: https://wiki.archlinux.org/index.php/Pacman_Rosetta
15 September 2015
•
[Rhythmic, dark electronic intro music] | |
League |
•
Hi welcome back to Command Line TV. This is episode 8. And what are we going to talk about today? |
Lopes |
•
Well last time we spoke about ImageMagick. We did a lot of image manipulations. •I guess today we’ll talk about package management and how to actually get •ImageMagick and other software onto the computer. |
League |
•
Yeah, it’s probably not installed by default on whatever system you’re •using so you definitely will have to install it. And package management is •an important topic in Linux systems and other Unixes because package •managers I think are one of the real advantages of Linux systems. •Basically when you want to install new software, there usually are these •archives or repositories of software that’s already been configured and •prepared to run on your system. So you just have to know the right commands •in order to search those and figure out what you need to install, and then get it installed. •These package managers also figure out the dependencies for you. •So if you have one piece of software that depends on other pieces of •software it can go and install all of them together and make sure that all gets managed. |
Lopes |
•
So I know on Windows you usually have an installation wizard that walks you •through every single step of installing software onto the system. •How does that differ using Ubuntu or Linux? |
League |
•
The way software is installed on Windows is a little different. •Those wizards might ask you some questions about like, where you’d like to install stuff. •That’s not usually a choice on the package managers on Linux systems – •they install in standard places. And sometimes the package managers will •ask other sorts of questions about configuration and so forth. •But the big difference is that windows packages tend to be either entirely self contained, •which means that you can install the software and you don’t need it to •install other pieces of software for you. Or in many cases for more complex •stuff you might have to chase those dependencies manually. •So I might want to install some IDE that requires the compiler to be installed separately first, •and then I have to tell the IDE where the compiler is and all sorts of things like that. •So the story on Windows is a little simpler and a little more complex, •it all depends on what you’re trying to accomplish. •But another problem that Windows suffered from for many years – •and it’s gotten way better recently – is what we call “DLL hell”. •And DLL is the dynamic libraries that Windows used. •What would happen is – there might be a very common library or dependency •of multiple software packages and that would be
represented as a file with the extension And then say you install package one which requires it and package two which requires it, •they will each bring their own but maybe install it in some central place •where they could conflict with each other. And so if one of them •over-installs the other one but they might be different versions and the •other one’s not expecting the new version – there are all kinds of problems that can happen. •And so a very strict system of package management helps tame this problem. •Each package specifies explicitly its dependencies and what versions of •those dependencies and in some cases it has facilities so that multiple •versions of the same software or same library can also be installed. •But this takes a lot of effort to put together and it’s one of the reasons •that Linux distributions put a lot of work into making this stuff as simple as possible. |
Lopes |
•
In today’s episode we’ll be using Ubuntu which uses ‘apt’ package manager •but what other options do we have in terms of package managers? |
League |
•
It all depends on the system that you’re running. The Debian and Ubuntu •systems use ‘apt’ as you mentioned, and other derivatives of them also use it. •RedHat systems and Fedora use
something called it pretty much provides the same type of facilities, the commands are just slightly different. •On my laptop I use ArchLinux, and
ArchLinux has a command called And then on the Mac, the Mac App Store is fine for these self-contained applications, •more like the Windows style. But if you want to install software that’s common on Unix, •including libraries and compilers and things like that – •you probably want to get a package manager on your Mac. •The one that seems to be popular now is called and it does package management a
lot like ‘apt’ or Historically on the Mac, there have been other ones. •There was one called MacPorts and ‘fink’ and a couple others – •but I think |
Lopes |
•
So like I said today we’ll be using my Ubuntu as opposed to your Linux. •Here we have my Ubuntu terminal. When we start with ‘apt’, •what would be one of the first things we would do in terms of finding downloads? |
League |
•
Yeah, so the command that is most useful for
finding stuff is called It’s all one command, but with a hyphen in it. And then you would do a •sub-command after that called the name of a package or something like that. Why
don’t we try searching for apt-cache search imagemagick• Try that. •And we got a lot of stuff out there – all of it has some relationship to ImageMagick, •but maybe we want to – I don’t know –
scroll up or pipe it through apt-cache search imagemagick | less• so we can look more carefully at those. Right •So near the top, I see Each line here is a package name followed by the space dash space, and then a description. •So You can see other ones that are interfaces for programming, •like it says “C++ interface to ImageMagick” and so on. •So let’s see if we can just find more information about one of those packages. •I’m going to quit the then the name of the package. In this case, it’s got to be the name of a package, apt-cache show imagemagick• not just a keyword. But this will give us a lot of details about this package, •including a longer description, and if we look up a little bit it has the version number – •this is It shows what other packages this depends on, and what versions it requires. •It’s a little bit flexible about – so
So if a new And then there’s a list of packages that it recommends or suggests. •These are not installed by default like the dependencies are, •but they might be other tools that work with it in some way, •and you might want to look at that list and get other ideas of things you might want to try. •So I think we’re ready to try and install this. The
command to install isn’t based on but it’s called and the name of the package. Yes, let’s try it. apt-get install imagemagick• Oh, what happened there? |
Lopes |
•
I still have to do |
League |
•
Yeah, permission denied, so sudo apt-get install imagemagick• assuming that we’re allowed to do that. And periodically with that you’ll have to type a password. •Okay, so it’s installing several
packages, in addition to It has some stuff here about
But now you should have the commands like
Just see if they’re available. which mogrify• Yeah, so on this system and we can start using them. |
Lopes |
•
So on Windows, normally once a program is installed it’ll update automatically. •How do we go about making sure all our programs are up to date on an Ubuntu device? |
League |
•
Some Ubuntu systems are configured to do what I’m about to show you periodically by itself. •If not though, it’s perfectly easy to do it yourself. •So what we’re going to do is run a command, also on
apt-get update• so repository and see what the latest versions – we do have to be admin for that too – sudo apt-get update• it’ll see what the latest versions are in these package repositories and •download the version information, so that we can see if there is new stuff •that needs to be downloaded. •And you see some of the hits here that we’re
contacting are so this is the repository where it keeps track specifically of security updates. •So now we’ve got the latest package lists and we want to see if there are new things to upgrade. •And that’s sudo apt-get upgrade• It will ask us to confirm after showing us the packages that it wants to upgrade. •So basically it says “the following packages were automatically installed and no longer required” – •I’ll show you how to get rid of those shortly. But the next section, •“the following packages will be upgraded” – those are things where there •are new versions available, so we can just press enter or say yes to let that happen. •And it’ll go and fetch those latest versions and install them. |
Lopes |
•
So on Windows we could easily access the “Program Files” to see what •applications we already have installed. How could I do the same thing using the command line? |
League |
•
So there’s a lower-level tool that’s part
of the ‘apt’ system called And if you run that with a dpkg -l• give you the complete list of all the installed packages. •Technically the and then following that is the package name, version, and description. •That was a lot of output so we could of course
use But also you can put a pattern right after the so we could see like what’s installed that has something to do with images, or something like that. •Yeah, dpkg -l 'image*'• Yeah, so this shows us that there’s a couple
of packages related to And one of them says but it may have been installed at some point previously, •or else it probably wouldn’t show up here at all. •Let’s go ahead and install that
sudo apt-get install imagemagick-doc• This is supposed to contain documentation for the system. |
Lopes |
•
Now that the |
League |
•
So the files that are actually installed as part of that package can be listed. •And that’s dpkg -L imagemagick-doc |
Lopes |
•
And that always has to be with the exact name, correct? |
League |
•
Right you can’t just use a wildcard in this case. So it gave us a whole list of files here, •which make up the documentation for
this dpkg -L imagemagick-doc | less• And a lot of them are in this folder
And there’s a bunch of You’re using other cool thing about you do the slash, so just hit And it jumped down and highlights an
that’s not the one I want. So just hit That’s part of to one that’s just part of the
So we can do that with of the code and not the rendered web page. So instead, •remember how we opened images –
there was Let’s try that – there’s a dash after the yeah sometimes you’ll be able to complete it
and sometimes not – and xdg-open /usr/share/doc/imagemagick-doc/index.html• Okay. •That opened up your web browser, and here’s a local web page – this didn’t go to the actual web. •See in your browser it says you’re browsing that has documentation for this entire system. •And that’s pretty cool, I like to have documentation packages installed a •lot because I might want to browse how to do something when I’m not even connected to the Internet. |
Lopes |
•
Now that we’ve learned how to install programs via the package manager, •how can we find out what commands, or what packages certain commands belong to. |
League |
•
Sure, so And here you can put a filename, path name, fragment of a path. •So let’s try one of the
dpkg -S mogrify• And this will show us a series of lines, each one has a package before the colon, •and then a filename after the colon. So this is all of the files on your •system that are installed by the package
manager that contain And so most of them of course come from
There is one strange one there, the
package is called And it’s got something called so the completion mechanism in your shell is when you hit Tab, •and it will complete the command that you’re typing. •The fact that also be able to complete the options for that command, which is pretty useful. •So let’s try out So let’s start to type That’s because You can also do just a dash you might have to hit Tab twice or something – and if there are a lot of •possibilities for completion it asks if you really want to see them all. •But now it’s showing you all of these
options that which is a crazy number of them. •But that’s just a useful thing that we
learned that because we went looking for all the
files that contain So today we spent a lot of time with Ubuntu’s package manager, •which is called ‘apt’, and we learned commands
like But there are other package managers for other systems. •The concepts that we learned will mostly carry over, •and what you’d have to do is figure out on a different packaging system, •the commands that are different. And it’s pretty easy to find on the web a translation guide – •if you’re used to ‘apt’, how do you do this in or if you are used to So maybe in the show notes we’ll have some links to some of those translations that are available. |
Lopes |
•
Another thing that I do, even though since I’m a beginner at Ubuntu still – •is I’ll use a web browser to search different packages and programs I can use. •And then practice that via the terminal. |
League |
•
Yeah so that search output, like when you’re looking for a package to do •something and you because there might be tons and tons of packages that have to do with your keyword, •but it’s hard to tell what’s what. So yeah, just searching the web and •using Google in general is going to help you hone in on what program you •might really be looking for. |
Lopes |
•
So what do we have in store for next episode? |
League |
•
I think next time we’re going to look at some more shell basics that we haven’t gotten to yet, •like redirection – this means taking the output of a command and saving it to a file, •or getting the input of a command from a file. We’re also going to look at •the back-quote character – it’s another way to combine different commands, •like the pipe, but it works in a different way. And the last thing I think •we’ll look at next time is symbolic links, which is kind of a way – •like we studied aliases – it’s a little like an alias but it works differently. •It’s a way of saving another name for the same content within the file system. •So we’ll get to those things next time, thanks for joining us. |
•
[Dark electronic beat] •[Captions by Christian Lopes and Christopher League] •[End] |