From the course: Linux Tips

Package management: Basics - Linux Tutorial

From the course: Linux Tips

Package management: Basics

- [Instructor] On a Linux system, we generally install and manage software using a package management tool. Package managers can retrieve software packages from repositories, or work with individual package files. They can unpack or build it as necessary, and put the resulting files into the locations across the system where they need to be placed. They keep track of what software is installed, and monitor for whether an updated version is available. And they can reverse the process, removing the files that a particular software package uses if the software is no longer needed. We can do all of these tasks by hand, but especially for large, wide ranging pieces of software, like a desktop environment or a suite of office software, doing so is prohibitively complex. And many packages rely on other packages, called dependencies, which must also be installed for that software to function. Package managers resolve these dependencies automatically. Depending on the distro you're using, you'll have a specific package manager available. Debian and the related distributions, like Ubuntu and Mint, use the APT package manager, which acts as a front end for the software called dpkg. CentOS and Red Hat use Yum, and Fedora uses DNF, which act as a front end for rpm, and so on. Different package management tools perform nearly identical tasks, though. They can search the repositories, download and install software, and update and remove it as necessary. Software developers and system administrators can create their own packages and repositories for software they need to distribute, and users or administrators can add or remove repositories from a list that the system uses to look for software. Most users, though, won't need to do these things. The repositories, or repos, which act as catalogs for software, are maintained by groups of people who test and add new software and updated versions of software to make it available to users. So, a particular piece or version of software might be available in the Ubuntu repositories, but not in the CentOS repositories because the teams that maintain each of those repositories have different guidelines for what software to provide. Generally speaking, though, you'll find the same software on offer across different distros, though they may have different versions. There are 10s of thousands of packages available, and the repositories are usually the first place to go to get common software. I mentioned earlier that different distros use different package managers, and that's also something to keep in mind when you're installing packages manually instead of through repositories. Primarily, you'll see package files ending with .deb and .rpm. .deb files are intended for use with dpkg, the package management software that the app software interfaces with. RPM files are for the RPM package manager, which Yum and DNF both interface with. Let's take a look at using the APT package manager to work with software here on an Ubuntu system. When you're using APT to install software from a repository, the first thing you want to do is make sure you have an up-to-date copy of the information available from the repo. And to do that with APT, I'll type apt update. That refreshes the list of software that the package manager can search and retrieve software from. Once you have some information about the software available, you can use commands like list, search, and show to find out what's available, and learn some more detailed information about packages. Let's look for one of my favorite pieces of software, which shows folders on the file system in a tree display. It's called Tree. I'll find it here with apt list tree. Okay, there it is. I see the name of the package, the particular repository it's available in, the version of the software, and the architecture it was built for. I can also find out more about the package by typing apt show tree. This shows the maintainer, how much space the package will take, a description, and some other information. Using list to see information about a particular package is fine if you know the exact name of the package you're looking for. But if you don't, and you want to search the descriptions of software to look for a match, you can do that with the search command. I'll search for directory tree, with apt search, and then my search term in quotes. And there's a handful of packages whose descriptions match. I'll scroll around a little, and here's Tree. Remember, if you're looking for something, it can be helpful to use apt show to get more details to see if it's what you're trying to find. To install the software, we'll use the install command. All right, apt install, tree. That goes to the repository and requests to download the package which contains the tree software, and the instructions for the computer about where all of the files in that package should be placed on the local system. I can see here that APT is building a dependency tree. That's one of the really helpful features about using a package manager. As I mentioned before, most software relies on other software in order to work, software like libraries and utilities, and so in order for an installed program to work correctly, a software package lists what it needs and the package manager goes out and gets that software as well, if it's not already installed. After that, we get a summary of what the package manager will do. Sometimes you'll see a comment about packages that the package manager found and are no longer required. And then, we see the action the package manager will take. This package will be installed. We see size information and the repository mirror, that is, the specific server address that the package manager will use to download the software. There's a progress indicator. In this case, it's already done because we needed just a small amount of data, and the process of installing the packages. This installation process can take a while for large packages and updates, so it's usually a good idea to run an upgrade or installation in something like Screen or tmux, so if your connection to the server is interrupted, you can reconnect and see the process going on. If you lose your SSH connection and come back, it's hard to figure out what the package manager is doing. Once software is installed, we can update it specifically with the apt upgrade command, which will check for updates for everything on the system. Here, I can see that the package manager has identified a handful of packages in need of an update, and I can choose whether to continue or not. I'll choose to go ahead by pressing Y. This can take a while, so we'll speed up the video here. And now my software is updated. If you're using a different package manager, you'll have similar commands. Take a look at the man page for your package management software to find out what they are.

Contents