Understanding Linux package managers is one of the first things a Linux user should do. It is a big part of what makes Linux so great, and knowing how package managers work is key to making life easy in the Linux world.
The Problem with Windows & Mac:
On my mac I have a video editing program called “Blender”. Somehow I managed to install it twice. One is 2 versions out of date.
In Windows and OSX there’s multiple ways to install things. You can use the Apple or Windows store… You can download from the internet, or you can use Homebrew or Macports for Mac (yes those are package managers.)
So we’ve got at least 3 different ways to install packages. If we want to see if something is installed already you have to look through your computer in various places.
Then you have to make sure everything is up to date. Without a package manager, the update process is fragmented. You go to each package and update it individually, and it just gets to be a pain. Windows/Mac users feel free to chime in! Am I missing something? Leave a comment.
Linux Package Managers to the rescue!
With Linux you have everything taken care of for you by the package manager. All of the software on your computer is managed by the package manager (for the most part).
All of the updates are handled by the package manager. You can install multiple packages at the same time. Even if you find some obscure package that isn’t in the package manager… You can put it in the package manager to keep track of it.
All in all… It makes managing software on your computer easier.
How to Use Your Package Manager:
All Linux package managers are pretty similar, so once you learn how to use one you for the most part know them all, with the exception of syntax. In this post we’ll cover Ubuntu’s manager.
Option A: GUI – Linux equivalent to the App Store
Most Linux distros have a GUI interface that looks just like an app store on Windows or Mac. Using the GUI accomplishes the same goal as using the command line, so either way works, but here’s how to use the GUI.
image 1 – Click the dots in the bottom left of the screen.
image 2 – click the ubuntu software center or search for it and click.
image 3 – search for and click the software you want
image 4 – click install and enter password.
Pretty simple right?
Option B: Using the command line (aka the elite hacker way)
Most Linux users live in the command line. So instead of opening the software center you can accomplish the same thing in your terminal. You can install as many packages as you want at a time by adding a space in between package names. Just run the code:
$ sudo apt install package1 package2 package3
Updating your package manager causes the system to look through all of the packages in the repository (every package you can install) and grab any updates that are available. That way all of your packages are up to date. You can update the system with this command (tap Y when it asks if you want to proceed):
$ sudo apt upgrade
You can also search the repository for a package with a command like this:
$ apt-cache search package-name
$ sudo apt remove package
Removing un-used dependencies
$ sudo apt autoremove
Packages not in the Repository: PPA’s
How Ubuntu finds & installs software
Universe – Community-maintained free and open-source software
Restricted – Proprietary drivers for devices
If you try to install a package that is not in any of those four repositories, you’ll get an error: “E: unable to locate package (package-name)”
Ubuntu knows where to look for packages because of your /etc/apt/sources.list file and your /etc/apt/sources.list.d/ directory.
So when you want to install a package that isn’t in those four repos you need the repository for that software in /etc/apt/sources.list or /etc/apt/sources.list.d/ You can check the README of the software, or check for the software on launchpad.net for proper installation instructions or just Google it and hope you find something. Most of the time the installation will look something like the following examples:
ATOM text editor:
ATOM is located inside the “webupd8team” repository. So we need to tell Ubuntu to look through the repository with webupd8team or grab just the specific package with webupd8team/atom.
$ sudo add-apt-repository ppa:webupd8team/atom $ sudo apt update $ sudo apt install atom
Cool. Because we did that “add-apt-repository” command… that adds webupd8team/atom to the /etc/apt/sources.list.d/ which tells APT to look for “atom” in that repo.
Add Repos with wget:
Sometimes the instructions have you add a key (for verification stuff) and add the repo manually… But if you break down the commands you’ll see almost the same result. Iridium’s current instructions look like this:
These commands are essentially saying “add the verification key. create the file iridium-browser.list in /etc/apt/sources.list.d/ with the contents (up until the EOF line)… Then update apt, then install iridium browser. You can even check the sources.list.d to see that new file there.
Hopefully that all makes sense so far! All your doing is telling your distro to check another repository for software.
Removing PPA’s & repositories
$ cd /etc/apt/sources.list.d/ $ sudo rm iridium-browser.list
Installing Software From Source with CheckInstall:
In cases like that you’ll want to install the software from source, but you don’t want to do the typical “make install”. Instead you’ll use “CheckInstall” or some other program depending on your distribution. Essentially you’re rolling it into your package manager on your own.
The package xcape is something we can use as an example. Xcape is a neat utility to adjust your modifier keys. I use it to set my CAPS lock to both Control and escape.
First, install CheckInstall. (Check their page first. Do their commands instead of what’s on this page in case it gets outdated.)
sudo apt-get update
sudo apt-get install checkinstall
$ sudo apt-get install git gcc make pkg-config $ sudo apt-get install libx11-dev libxtst-dev libxi-dev $ git clone https://github.com/alols/xcape.git $ cd xcape $ make $ sudo checkinstall
Then follow the prompts for a description of the package and all that stuff and bam you’ve got the software on your system, but even better is this random package isn’t floating around somewhere on your system. It’s right where all the other software is, and you can remove it completely and easily.
You can also see that package is installed when doing a search through the rest of your installed packages that are managed by the package manager. After you’ve installed xcape, run the list command and you’ll see that xcape is in the list of installed software!:
$ apt list --installed
According to Checkinstall you’re supposed to remove packages with:
$ sudo dpkg -r packagename
and that works, but even more interesting is that it appears that the standard APT commands also allow you to remove the software:
$ sudo apt remove xcape
So take your pick I guess… Last thing is you don’t want that xcape folder lying around, so delete the folder that you downloaded from Github, (it’s installed so you don’t need the folder anymore) and I think you should be all set!
Linux package management is pretty easy once you know how to do it. Everything is nice and tidy and you can manage all your software right in one place. If I missed anything got something wrong or outdated, or if you have anything to add, please leave a comment! We’d love to hear from you.