Vijay installs software without an installer wizard
apt, yum, pip — package management for Windows engineers
Vijay had been on Linux for 5 weeks. He knew the basics. But every time he needed to install something, he froze. On Windows the answer was always the same: find the website, download the .exe or .msi, double-click, click Next a few times, done. On Linux his colleagues just typed one line and the software appeared.
PACKAGE MANAGERS — THE LINUX APP STORE
A package manager installs, updates, and removes software. It handles all dependencies automatically. You never visit a website to download software.
Two major package managers:
- apt — Ubuntu, Debian, Linux Mint
- yum / dnf — CentOS, RHEL, Amazon Linux, Fedora
Which one do you have?
cat /etc/os-release # see your Linux distribution
# Ubuntu/Debian: use apt
# CentOS/RHEL/Amazon Linux: use yum or dnfAPT — UBUNTU AND DEBIAN SERVERS
# Update the list of available packages (like Windows Update checking for updates):
sudo apt update# Install a package:
sudo apt install nginx
sudo apt install python3-pip
sudo apt install -y git curl wget unzip # -y skips the yes/no prompt# Remove a package:
sudo apt remove nginx # remove but keep config files
sudo apt purge nginx # remove AND config files
sudo apt autoremove # remove packages no longer needed# Search for a package:
apt search nginx
apt-cache search "text editor"# See info about a package:
apt show nginx # version, description, dependencies# List installed packages:
dpkg -l # all installed packages
dpkg -l | grep nginx # is nginx installed?
dpkg -l | wc -l # how many packages installed?# Upgrade all packages (like Windows Update install all):
sudo apt update && sudo apt upgrade -y# Upgrade everything including kernel:
sudo apt update && sudo apt full-upgrade -yYUM / DNF — CENTOS AND RHEL SERVERS
sudo yum install nginx # install
sudo yum remove nginx # remove
sudo yum search nginx # search
sudo yum info nginx # package info
sudo yum update # update all packages
sudo yum list installed # list installed packages
sudo yum list installed | grep nginx # is nginx installed?# dnf is the modern replacement for yum (same commands):
sudo dnf install nginx
sudo dnf updateINSTALLING THINGS NOT IN THE PACKAGE MANAGER
Sometimes a package is not in the default repositories. Three approaches:
Approach 1: Add a repository
# Example: adding NodeJS official repository
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo bash -
sudo apt install nodejs# Example: adding Docker's official repository
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker.gpg
echo "deb [signed-by=/usr/share/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list
sudo apt update
sudo apt install docker-ceApproach 2: Download a .deb or .rpm file directly
wget https://example.com/software.deb
sudo dpkg -i software.deb # install .deb (Ubuntu/Debian)
sudo rpm -i software.rpm # install .rpm (CentOS/RHEL)Approach 3: Download a binary directly
wget https://example.com/mytool-linux-amd64
chmod +x mytool-linux-amd64
sudo mv mytool-linux-amd64 /usr/local/bin/mytool
mytool --version # now available as a commandPYTHON PACKAGES — PIP
pip3 install requests # install a Python package
pip3 install -r requirements.txt # install from requirements file
pip3 list # list installed packages
pip3 show requests # info about a package# Virtual environment (isolate dependencies per project):
python3 -m venv myenv # create virtual environment
source myenv/bin/activate # activate it
pip3 install requests # installs only in this env
deactivate # back to system PythonWHICH VERSION IS INSTALLED?
nginx -v # nginx version
python3 --version # Python version
node --version # Node.js version
git --version # git version
java -version # Java version
dpkg -l nginx | grep nginx # full installed version from package managerFINDING WHERE A PACKAGE INSTALLED ITS FILES
dpkg -L nginx # list all files installed by nginx package
which nginx # where is the nginx executable?
whereis nginx # all locations: binary, config, man pageVijay's takeaway after learning package management: apt install is faster than finding a download link, running an installer wizard, and clicking through licence screens. One command. Done. Every time.
apt install name replaces downloading an .exe and running a wizard — one command installs software and all dependencies
sudo apt update first, then sudo apt install — update updates the package list, install actually installs
dpkg -l | grep name checks if a package is installed — faster than opening Programs and Features
apt purge removes software AND its config files — apt remove keeps configs in case you reinstall
python3 -m venv creates an isolated Python environment — equivalent to having separate software installs per project