Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Install Program with apt-get: Step-by-Step

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To install a program with apt-get, you run sudo apt-get install [package-name] in a terminal. This command downloads the package from your configured repositories and installs it, along with any dependencies. You need a Debian-based Linux system (like Ubuntu) and sudo privileges. This guide covers the full process, from updating your package list to verifying the installation.

What You'll Need

  • A Debian-based Linux distribution (Ubuntu, Debian, Linux Mint, etc.)
  • Terminal access (Ctrl+Alt+T on most systems)
  • An account with sudo privileges (the ability to run commands as root)
  • An internet connection to download packages

Step-by-Step

  1. Open a terminal. Press Ctrl+Alt+T or search for “Terminal” in your applications menu.
  2. Update your package list. Run sudo apt-get update. This refreshes the list of available packages and their versions from the repositories. It does not install anything, but it ensures you get the latest version and that the system knows about new packages.
  3. Find the exact package name. If you don't know the exact name, search for it: apt-cache search [search-term]. For example, apt-cache search video editor lists packages related to video editing. Note the exact package name from the output.
  4. Install the package. Run sudo apt-get install [package-name]. Replace [package-name] with the actual name, e.g., sudo apt-get install vlc. You'll be prompted for your password, then the system will show you what will be installed and ask for confirmation. Type Y and press Enter.
  5. Wait for the download and installation. The terminal will show progress bars. Once finished, the prompt returns and the program is installed.
  6. Verify the installation. Run [package-name] --version or just type the package name and press Enter to launch it. For example, vlc --version shows the version, and vlc launches the app.

Common Mistakes

  • Forgetting sudo. apt-get needs root privileges. Without sudo, you'll get a “Permission denied” error.
  • Not updating first. If you skip sudo apt-get update, you might get “Package not found” errors or install an outdated version.
  • Typing the wrong package name. Package names are case-sensitive and often have hyphens. Use apt-cache search to confirm.
  • Assuming the package is in the default repositories. Some software is not in the official repos and requires adding a PPA or downloading a .deb file. apt-get will fail with “Unable to locate package” if it's not available.

Tips

  • Use apt instead. On modern Ubuntu and Debian, apt is a friendlier wrapper. It does the same thing but with nicer output and color. For example, sudo apt install vlc.
  • Install multiple packages at once. List them all: sudo apt-get install vlc gimp inkscape.
  • Use -y to skip confirmation. sudo apt-get install -y vlc automatically answers “yes” to the prompt. Useful for scripts, but be careful.
  • Clean up after. sudo apt-get autoremove removes packages that are no longer needed. sudo apt-get clean clears the downloaded .deb files from the cache.
  • Check what's installed. apt list --installed shows all installed packages.

Troubleshooting

If the installation didn't go as planned, work through these in order.

  1. “Unable to locate package” – This means the package isn't in your repositories. First, run sudo apt-get update again. If it still fails, the package might be named differently (use apt-cache search) or not available in the official repos. You may need to add a PPA or download a .deb from the developer's website.
  2. Dependency errors – If you see “Unmet dependencies,” try sudo apt-get -f install. This fixes broken dependencies. If that doesn't work, try sudo apt-get update then sudo apt-get upgrade to bring the system up to date, then retry the install.
  3. “Could not get lock /var/lib/dpkg/lock” – Another apt process is running. Wait for it to finish, or if it's stuck, reboot the system. Do not delete the lock file manually unless you're sure no other package manager is running.
  4. Package is installed but doesn't run – Check if the command name differs from the package name. For example, the package firefox runs as firefox, but some packages use a different binary name. Use dpkg -L [package-name] to list files installed by the package and find the executable.
  5. Network issues – If downloads fail, check your internet connection. You can also try a different mirror in Software & Updates (on Ubuntu) or /etc/apt/sources.list.
  6. If all else fails – Reinstall the package: sudo apt-get purge [package-name] (removes config files too) then sudo apt-get install [package-name] again.

Frequently Asked Questions

What's the difference between apt-get and apt?

They both install packages, but apt is a newer, more user-friendly interface. It combines the functions of several apt-get commands and provides better progress bars. For most users, apt is recommended, but apt-get still works and is preferred in scripts.

Do I need to run update every time before installing?

It's strongly recommended. The update refreshes the list of available packages and their versions. If you don't, you might install an older version or get errors if the package list is stale.

How do I uninstall a program installed with apt-get?

Use sudo apt-get remove [package-name] to uninstall but keep configuration files. Use sudo apt-get purge [package-name] to remove everything including configs.

Can I install a .deb file with apt-get?

No, apt-get works with repositories. To install a .deb file, use sudo dpkg -i /path/to/file.deb. If there are dependency errors, follow with sudo apt-get -f install.

Why does apt-get ask for my password?

Because installing software changes system files, which requires administrator (root) privileges. sudo prompts for your password to confirm you have the right to make these changes.

Is it safe to use sudo apt-get upgrade?

Yes, it's generally safe. It upgrades all installed packages to their latest versions from the repositories. However, it won't remove packages or change your system configuration. For major version upgrades (like from Ubuntu 22.04 to 24.04), use the release upgrade tool instead.