The Short Answer
Give apt the path to the file. The ./ matters: without a path, apt looks for a package by that name in its repositories instead of reading the file.
sudo apt install ./package_1.2.3_amd64.deb
apt reads the dependencies listed inside the file, downloads the missing ones from your configured repositories, and installs everything in one step. The same command works on Debian.
If the file sits in a folder that the _apt system user cannot read, such as root's home folder, apt may print a note that the download is performed unsandboxed as root. The note is harmless; moving the file to /tmp avoids it.
Get the File onto the Server
Download it on the server itself, or copy it from your computer with scp. To download, see how to download a file with curl:
cd /tmp
curl -LO https://example.com/downloads/package_1.2.3_amd64.deb
Match the architecture. Run dpkg --print-architecture: most servers print amd64, ARM servers print arm64. File names end in the architecture, or in all for packages that run anywhere.
Check the Package Before You Install It
A .deb file can run scripts as root while it installs. Installing one means trusting whoever built it with full control of the server. Prefer the distribution's own packages, then the vendor's own download page over HTTPS. If the vendor publishes a checksum, compare it:
sha256sum package_1.2.3_amd64.deb
dpkg-deb --info package_1.2.3_amd64.deb
dpkg-deb --contents package_1.2.3_amd64.deb
--info shows the package name, version, and dependencies, and lists the install scripts it carries. --contents lists every file it will place on the system. Some vendor packages also add their own repository under /etc/apt/sources.list.d/ so that later versions arrive with normal updates; look in that folder after installing.
The dpkg Route
dpkg is the lower-level tool. It installs the file but does not download anything:
sudo dpkg -i package_1.2.3_amd64.deb
sudo apt -f install
If a dependency is missing, dpkg stops with a dependency error and leaves the package unpacked but not configured. apt -f install (the long form is --fix-broken) downloads what is missing and finishes the setup. If the dependencies cannot be met, it proposes removing the package instead, so read its plan before you answer yes.
Common Errors
- Unable to locate package: the
./or the full path is missing, so apt searched the repositories. - Unmet dependencies: the package was built for a newer release and needs library versions yours does not have. Look for a build made for your release. Do not force it with dpkg options that ignore dependencies.
- Wrong architecture: an
arm64file on anamd64server, or the other way round. Download the matching file. - Could not get lock: another package process is running. See how to fix the dpkg lock error.
- Conflicts with an installed package: the file wants to replace something already on the system. Read which package it names before removing anything.
Confirm It Is Installed
The package name is not always the file name. Read it from the file, then query it:
dpkg-deb -f package_1.2.3_amd64.deb Package
apt show package
dpkg -L package
dpkg -L lists the files the package installed, which helps you find its binary and configuration.
Remove the Package
| Command | What it does |
|---|---|
sudo apt remove package | Removes it, keeps its configuration |
sudo apt purge package | Removes it and its configuration |
sudo apt autoremove | Removes dependencies nothing needs |
If the package added a repository, remove that file from /etc/apt/sources.list.d/ and its key, then run sudo apt update.
Updates for a Package Installed from a File
A package installed from a file is not updated by apt upgrade unless it added a repository. Watch the vendor's releases and install the newer file the same way; apt upgrades it in place. To learn what the regular update commands do, see sudo apt update.