Install Program with apt-get: Step-by-Step
In this article
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
- Open a terminal. Press
Ctrl+Alt+Tor search for “Terminal” in your applications menu. - 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. - 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 editorlists packages related to video editing. Note the exact package name from the output. - 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. TypeYand press Enter. - Wait for the download and installation. The terminal will show progress bars. Once finished, the prompt returns and the program is installed.
- Verify the installation. Run
[package-name] --versionor just type the package name and press Enter to launch it. For example,vlc --versionshows the version, andvlclaunches the app.
Common Mistakes
- Forgetting
sudo.apt-getneeds root privileges. Withoutsudo, 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 searchto 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-getwill fail with “Unable to locate package” if it's not available.
Tips
- Use
aptinstead. On modern Ubuntu and Debian,aptis 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
-yto skip confirmation.sudo apt-get install -y vlcautomatically answers “yes” to the prompt. Useful for scripts, but be careful. - Clean up after.
sudo apt-get autoremoveremoves packages that are no longer needed.sudo apt-get cleanclears the downloaded .deb files from the cache. - Check what's installed.
apt list --installedshows all installed packages.
Troubleshooting
If the installation didn't go as planned, work through these in order.
- “Unable to locate package” – This means the package isn't in your repositories. First, run
sudo apt-get updateagain. If it still fails, the package might be named differently (useapt-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. - Dependency errors – If you see “Unmet dependencies,” try
sudo apt-get -f install. This fixes broken dependencies. If that doesn't work, trysudo apt-get updatethensudo apt-get upgradeto bring the system up to date, then retry the install. - “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.
- Package is installed but doesn't run – Check if the command name differs from the package name. For example, the package
firefoxruns asfirefox, but some packages use a different binary name. Usedpkg -L [package-name]to list files installed by the package and find the executable. - 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.
- If all else fails – Reinstall the package:
sudo apt-get purge [package-name](removes config files too) thensudo 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.