Intermediate · 8 min · practise every command in the built-in terminal

Installing and Removing Packages

Install a package

sudo apt install htop
sudo apt install htop tree curl     # Multiple at once
sudo apt install -y htop            # Auto-confirm prompts

Remove a package

sudo apt remove htop        # Removes the program, keeps config files
sudo apt purge htop         # Removes the program AND its config files

Clean up leftover dependencies

sudo apt autoremove         # Removes packages that were only installed as dependencies and are no longer needed
sudo apt autoclean          # Clears out old downloaded .deb files from cache

Reinstall a package

sudo apt install --reinstall htop

Pin / hold a package version

sudo apt-mark hold htop     # Prevent htop from being upgraded
sudo apt-mark unhold htop

Typical workflow

sudo apt update
sudo apt install nginx
sudo apt remove --purge htop
sudo apt autoremove

Practice tasks

  1. Install the 'htop' package
  2. Remove the 'htop' package along with its config files
  3. Install multiple packages in a single command
  4. Clean up dependencies that are no longer needed

Commands in this lesson

Package Management