In this article, we show you how to install software packages in Debian 9 and how to find out in which repository the software can be found.
Follow the steps in this article from command-line as root user, or with sudo.
Installing a package
In Debian 9, you install packages with the following commands:
apt -y install packagename
apt-get -y install packagename
Apt / apt-get is a meta package handler / package manager with which you can manage packages, for example, or create repositories.
By adding -y, you automatically give permission when you are asked for permission to install the relevant package.
Finding out in which package software is included
Do you want to use a command, but does Debian say that the command cannot be found? Then you can find out if you can install it by checking if it is part of a package that is included in a repository which you use in Debian. You do this with the command:
apt search commandname
If you want to use netstat, for example, you use the command:
apt search netstat
For example, the output looks like this:
Sorting... Done Full Text Search... Done bwm-ng/stable 0.6.1-2 amd64 small and simple console-based bandwidth monitor gnome-nettool/stable 3.8.1-1+b2 amd64 network information tool for GNOME golang-github-aelsabbahy-gonetstat-dev/stable 0.0~git20160428.0.edf89f7-2 all Netstat implementation in Go libparse-netstat-perl/stable 0.12-1 all module to parse the output of the "netstat" command net-tools/stable 1.60+git20161116.90da8a0-1 amd64 NET-3 networking toolkit etc. etc.
Therefore, to use the netstat command, you install net-tools in this case:
apt install -y net-tools
You may wonder how you know that net-tools was the right search result. When you see a large number of search results, it is best to search the Debian package page under 'Search the contents of packages' on the relevant command/software.
As a rule, you will always need the top result on this page or at least the command which is in the /bin or /usr/bin directory. In this example, you will also see results such as dnetstat, snmpnetstat at netstat, which are clearly not the same.
Finding out in which repository software is included
It may happen that the software you want to install is not included in a repo that you are currently using. In that case, the relevant software cannot be installed.
You can exclude whether this is the case by seeing if the software is part of a package included in your current repositories. You use the following command for this:
apt search packagenaam
When you see nothing more than 'Unable to locate package packagename' or ...
Sorting... Done Full Text Search... Done
... this means that the required package does not exist or is part of another repository.
In Linux, the idea is that for security reasons, you can only search and install software in your own sphere of influence, but not outside it. So, you have access to repositories which you have installed, but you cannot perform a search in uninstalled repositories. The only option to find out in which repository a package is included if you have not yet installed the repository is to look it up via a search engine such as Google, the Debian package page, or for example on Gitlab.
Updating packages
You can easily update all installed software in Debian with one of the commands:
apt -y update
apt-get -y update
Adding a repository
You can add repositories in two ways.
- The first is from command-line. You first need the software-properties-common package:
Then, add a repository with the command:
apt install -y software-properties-common
See the explanation at the bottom of this section for an explanation of the code.add-apt-repository deb http://site.example.com/debian distribution component1
- The available Debian repositories can be found in the /etc/apt/sources.list file and you can, for example, open them with:
Remove / uncomment the # in front of the line starting with # deb for the repository you want to add, or manually add a new repo with the syntax:
nano /etc/apt/sources.list
Then, save your changes (ctrl + x> y> enter) and update the available package list:add-apt-repository deb http://site.example.com/debian distribution component1
apt-get -y update
The rules you see in this file are made up of:
- deb: the repositories containing the binaries and precompiled packages.
- deb-src: these repositories also contain the source code of packages and are only useful for developers.
- http://acrhive.ubunu.com/debian: where the repository can be found.
- distribution: the release name of the Debian 9.
- main & restricted: the section names of the repository.
This concludes this guide on installing software in Debian 9. Should you have any questions left regarding this article, do not hesitate to contact our support department. You can reach them via the ‘ContactUs’ button at the bottom of this page.
If you want to discuss this article with other users, please leave a message under 'Comments'.