Installing software on Ubuntu or Debian is usually straightforward: choose a package name, ask APT to install it, and review what APT plans to change. The useful part is knowing what the command does—and what to check when it doesn't work.
The basic command
sudo apt install tree
Here, sudo runs the command with administrator privileges, apt is the package-management command-line interface, and install tells it to install the package that follows. In this example, that package is tree.
You don't install apt or sudo with this command. They're normally already available on Ubuntu and Debian systems. The package name goes after install, and it may not match the name of the command or application it provides.
To inspect a package before installing it, check its available metadata:
apt show tree
APT uses package information from the repositories configured on your system. It resolves dependencies, downloads the needed files, and installs them. You may be prompted for your account password; the terminal usually won't show characters while you type. Your account must be allowed to use sudo. If sudo itself is unavailable, first diagnose why the command is missing or failing rather than trying to bypass permissions.
When to run apt update
APT keeps a local index of packages and versions available from configured repositories. Refresh that index when it may be stale—for example, after setting up a system, changing repository configuration, or getting an “Unable to locate package” error.
sudo apt update
sudo apt install tree
apt update downloads repository metadata. It does not install package updates. You don't necessarily need to run it immediately before every installation if the index is already current.
If the update reports a network or repository error, resolve that first. A failed update can leave APT relying on old package information. Don't start by adding repositories or a PPA; check the spelling of the package name, your distribution release, and which repositories are enabled.
Read the proposed changes before confirming
APT may list the requested package, dependencies, download size, and estimated disk-space changes before asking you to continue. Review that summary. Enter Y or press Enter to proceed; enter n to cancel.
You can install several packages in one operation:
sudo apt install tree curl
APT resolves dependencies for both. If the planned packages or disk-space changes are surprising, cancel and investigate. Avoid adding -y by habit: it skips the interactive confirmation, so you lose the chance to review the plan before changes are made.
Confirm that the package installed
After APT finishes without an error, check the package status:
dpkg -s tree
Look for Status: install ok installed. You can also check the command, if the package provides one:
tree --version
A package name and its executable name aren't guaranteed to be identical, and some packages don't provide a command to launch. For example, a library or background component may not open a window or have a useful version command.
Troubleshooting common failures
“Unable to locate package”
APT couldn't find that name in its current package lists. Check the spelling, refresh the index if needed, and search for related names:
sudo apt update
apt search tree
apt policy tree
Availability depends on your distribution release and enabled repositories. If a command isn't packaged under the name you expect, search for the package that provides it rather than assuming the command and package names match.
Another package manager is running
APT uses locks to prevent simultaneous changes to the package database. If a system update or another installation is active, wait for it to finish and try again. Don't delete lock files to force an installation; that can leave package management in an inconsistent state.
An interrupted installation or dependency error
Read the full error and use repair commands only when they match the problem reported. If APT explicitly says package configuration was interrupted, the usual command is:
sudo dpkg --configure -a
If APT reports unmet dependencies, this may propose a repair:
sudo apt --fix-broken install
Review the proposed changes before confirming. Avoid forcing dependencies or removing packages without understanding the consequences. If you downloaded a local .deb file rather than installing from configured repositories, that's a different workflow; see this guide to installing a downloaded .deb package.
apt or apt-get?
Both apt install and apt-get install install packages from configured APT repositories. For commands typed in a terminal, apt is a convenient front end. apt-get is still supported and is often used in scripts because its command-line behavior is designed to be more stable for automation.
The everyday workflow is simple: check the package name, refresh package lists if they're stale, run sudo apt install, and read the proposed changes before accepting. If something fails, use the exact error to guide the next step instead of making broad changes to your system.
I originally published a more detailed version of this guide on the SSHFlow blog.
I'm also building SSHFlow — an SSH client where every server gets its own workspace for terminals, SFTP, code, and databases.
Top comments (0)