Using the Raspbian Repository with apt-cache and apt-get
Learn how to search, inspect, install, and remove Raspbian packages from the terminal using apt-cache and apt-get.
A Raspbian repository is a configured source of packaged software for a Raspberry Pi running Raspbian. It provides a catalog of applications, libraries, utilities, and other supporting components that APT can download and install.
Because Raspbian is derived from Debian, it can use a large collection of Debian-compatible packages built for ARM processor architectures used by Raspberry Pi devices. Instead of downloading separate installers manually, you can use the repository to obtain software such as browsers, text editors, games, and server applications.
This lesson assumes that you can open a terminal, enter commands, interpret basic terminal output, and connect the Raspberry Pi to the network. For an introduction to the terminal, see Terminal in Raspbian.
What APT Does
APT means Advanced Package Tool. It is the package-management system used by Raspbian and other Debian-derived distributions.
A package is a distributable unit of software together with metadata describing it. APT can install a package and resolve its dependencies. A dependency is another package required for the requested software to work, such as a library or supporting utility.
APT includes several command-line utilities. In this lesson:
- apt-cache queries package metadata that is available locally. It can search for packages and display their details.
- apt-get performs package-management actions such as installing and removing packages.
- sudo runs a command with elevated administrative privileges.
The administrative account is called root. Installing or removing system-wide software changes protected parts of the operating system, so those actions normally require sudo. Searching and inspecting locally available metadata do not normally require it.
Search the Repository with apt-cache
Use apt-cache search to search repository metadata:
apt-cache search SEARCH_TERMThe search can match package names and package descriptions. A broad term may return many results, so read the output carefully and look for an exact package name that appears suitable for your goal.
Example: Find Chess Software
To look for chess-related software, run:
apt-cache search chessThe output may contain several chess games, engines, libraries, or related tools. One matching package is named dreamchess. The name shown at the beginning of a result is the package name to use in later commands.
Do not assume that an application's informal name is also its package name. Use the exact package name returned by the search.
Inspect Package Details with apt-cache
After finding a possible package, inspect its metadata before installing it:
apt-cache show PACKAGE_NAMEFor the chess example, run:
apt-cache show dreamchessThe result is package metadata. Common fields include:
Checking these details can prevent mistakes, reveal the expected disk-space impact, and confirm that the package is suitable before you authorize changes to the system.
Install a Package with apt-get
Use this syntax to install a package:
sudo apt-get install PACKAGE_NAMETo install DreamChess, use the exact package name found by the search:
sudo apt-get install dreamchessWhen you run this command, sudo may ask for your user password. The password gives the command administrative authority; it is not displayed while you type it.
APT checks the package's dependencies and may propose downloading and installing additional packages. It also normally displays a summary of packages, download size, and disk-space changes, followed by a confirmation prompt. Review the proposed changes and confirm only when they are expected.
Do you want to continue? [Y/n]After installation completes, the application is available through the normal application menu or by the command provided by that package.
Remove an Installed Package with apt-get
To remove an installed package, use:
sudo apt-get remove PACKAGE_NAMEFor the example application:
sudo apt-get remove dreamchessReview the removal summary and confirm it when prompted. The remove action removes the application package, but it may leave configuration files behind. This can be useful if you might reinstall the application and want its settings retained.
APT Command Reference
Package Availability and Current Metadata
Package availability depends on the installed Raspbian release, the device's architecture, and the repository sources configured on the Raspberry Pi. A package available for one release or architecture may not be available for another.
APT uses local package metadata to perform searches and select packages. That metadata must be current, and the configured repositories must be reachable, for searches and installations to work reliably. If metadata is old, update the package lists before repeating a search or installation:
sudo apt-get updateThis command updates package lists; it does not itself install or remove the applications listed in those sources.
For broader system update guidance, see Update Raspbian. To understand repository configuration in more depth, see Synaptic Package Manager as a graphical package-management alternative.
Troubleshooting APT Searches and Installs
The desired program does not appear in search results
- Try broader or alternative search terms. A description may use different wording from the application name.
- The package may not be available for the installed Raspbian release or the Raspberry Pi's architecture.
- Local package metadata may be outdated, or the configured repository sources may be unavailable.
- Check the network connection and update package lists with
sudo apt-get update.
APT says it cannot locate the package
- Search again and copy the exact package name from the result.
- Check for typing errors and avoid substituting an informal application name.
- Confirm that the appropriate Raspbian repositories are configured and reachable.
- Refresh package metadata if it does not reflect current repository contents.
A permissions error appears
Install and remove operations modify system-wide software and require administrative privileges. If your account is authorized to use sudo, repeat the operation with sudo before apt-get:
sudo apt-get install PACKAGE_NAMEAPT proposes additional packages
The requested application has dependencies. Read the dependency and disk-space summary, then confirm only if the proposed changes are appropriate. Installing dependencies is normal when an application relies on shared libraries or supporting packages.
Practical Workflow
- Search for a category or application keyword with
apt-cache search. - Review the results and identify the exact package name.
- Inspect that package with
apt-cache show. - Check its version, architecture, size, dependencies, homepage, and description.
- Install it with
sudo apt-get installand review the confirmation summary. - When it is no longer needed, remove the exact package with
sudo apt-get remove.