← Operating Systems from Zero: Linux, Windows and macOS

Video coming soon

The written lesson below is ready now. The video is being published on our YouTube channel.

Follow ChangeCV on YouTube →

Lesson 6 of 6

Package managers: apt, Homebrew and winget

Install, list and remove software from the terminal, with an app-store analogy. Five steps shown with apt on Ubuntu, Homebrew on macOS and winget on Windows, using the jq tool as the example.

The idea in plain words

Think of an app store for the terminal. The package list is the shop catalogue, and refreshing it downloads the latest version of the catalogue. Install downloads the software and sets it up, and remove tidies up.

The same small tool, jq, has one name on Ubuntu and Homebrew and a different id on winget, but the five steps are the same everywhere.

Commands in this lesson

sudo apt update
Refresh the package list. On macOS use brew update, and on Windows winget source update.
apt search jq
Search for a package. On macOS use brew search jq, and on Windows winget search jq.
sudo apt install jq
Install a package. On macOS use brew install jq, and on Windows winget install jqlang.jq.
apt list --installed
List what is installed. On macOS use brew list, and on Windows winget list.
sudo apt remove jq
Remove a package. On macOS use brew uninstall jq, and on Windows winget uninstall jqlang.jq.

Written notes from the video

Install software from the terminal

You do not have to download installers from random websites. This is Operating Systems from zero, episode six: package managers. Five steps to install and remove software, the safe way.

The app store for the terminal

Think of an app store for the terminal. The package list is the shop catalogue. Install downloads the program and sets it up. Remove tidies up afterwards. We will use one example on all three systems: a small tool called jq.

Step 1: refresh the list

Step one: refresh the list. On Ubuntu, sudo apt update downloads the latest catalogue. It reads the package lists, and tells you how many packages can be upgraded. On macOS, the package manager is Homebrew, and the command is brew update. On Windows, winget source update does the same.

Step 2: search

Step two: search. apt search jq finds packages that match the word. Each result shows the name, the version, and a short description. On macOS, use brew search. On Windows, use winget search.

Step 3: install

Step three: install. sudo apt install jq asks for confirmation, then downloads and sets up the program. Now jq --version prints jq-1.7.1. On macOS, use brew install jq. On Windows, use winget install jqlang.jq.

Step 4: list installed

Step four: see what is installed. apt list --installed shows every package on the system. Pipe it to grep jq to find just one. On macOS, use brew list. On Windows, use winget list.

Step 5: remove

Step five: remove. sudo apt remove jq takes the program off the system. On macOS, the command is brew uninstall jq. On Windows, winget uninstall jqlang.jq. Install only from sources you trust.

On Windows and macOS

On Windows PowerShell, winget searches, installs, lists and removes programs. The package id is jqlang.jq, and you use that id to install and to remove it. On macOS, Homebrew is not preinstalled. Install it from brew.sh first. Other Linux systems use their own tools, like dnf on Fedora, and pacman on Arch.

Recap

Recap. Refresh the list, search, install, list what you have, and remove. Three systems, one idea, and the same tool: jq.

Course complete

That is the end of Operating Systems from zero. You can now move around, manage files, run commands and install software. Find written notes for every lesson, free, at changecv.com/skills.

Common questions

Is Homebrew already installed on a Mac?

No. Homebrew is a separate tool that you install from brew.sh. Once it is installed, the brew commands in the lesson work.

Why do I need sudo for apt install but not for brew?

apt changes system folders, so it needs administrator rights. Homebrew installs into its own folder that belongs to your user, so it does not use sudo.

Why refresh the package list before installing?

The list is a local copy of the catalogue. Refreshing it makes sure you see the newest versions and do not install something out of date.

What do I use on other Linux systems?

apt is for Ubuntu and Debian. Fedora uses dnf and Arch uses pacman. The five steps are the same, only the command names change.

Is it safe to install any package?

Only install software from sources you trust. A package can run code with the rights you give it, so check the name and the publisher first.