Cyberithub

How to Add a Package Repository to Debian 11

Advertisements

In this article, I will take you through the steps to add a package repository to Debian 11. If you are looking to download and install packages from Debian repository then all you need to do is to add the right repository sources in your Debian Server. Then you can use any package manager like apt or apt-get to install the package from it by using just a single command. It will take care of all the dependencies and hence you don't have to install all the dependent packages manually.

Similarly, if you want to remove any package then you can do that as well by using apt or apt-get package manager in a single command. So with all this information let's see how to add a package repository to Debian 11 and install a sample package in below section. You can always refer to Debian Sources List to check about the repository sources.

Advertisements

How to Add a Package Repository to Debian 11

How to Add a Package Repository to Debian 11

Also Read: How to Install OpenSSH Server on Debian 11

Step 1: Prerequisites

a) You should have a running Debian 11 Server.

Advertisements

b) You should have sudo or root access to run privileged commands.

c) You should have apt or apt-get utility installed in your Server.

Advertisements

 

Step 2: Add a Package Repo

You need to open /etc/apt/sources.list file using nano editor and then add the below repository source at the beginning of the file. Then save and close the file by using Ctrl+X.

deb http://deb.debian.org/debian bullseye main
deb-src http://deb.debian.org/debian bullseye main

You can then verify the contents of the file by using cat /etc/apt/sources.list command as shown below.

Advertisements

How to Add a Package Repository to Debian 11 2

 

Step 3: Update Your Server

In the next step, you need to update your packages by using apt update or apt-get update command as you can see below. This will download and install all the latest updates from the Debian repository.

How to Add a Package Repository to Debian 11 3

 

Step 4: Install a Package

After setting up the repository, you can now install a package using apt-get install command. To test the repository setup, here I am installing default JDK package using apt-get install default-jdk command as you can see below.

root@debian:~# apt-get install default-jdk
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
ca-certificates-java default-jdk-headless default-jre default-jre-headless java-common libatk-wrapper-java libatk-wrapper-java-jni libice-dev
libpthread-stubs0-dev libsm-dev libx11-dev libxau-dev libxcb1-dev libxdmcp-dev libxt-dev openjdk-11-jdk openjdk-11-jdk-headless openjdk-11-jre
openjdk-11-jre-headless x11proto-dev xorg-sgml-doctools xtrans-dev
Suggested packages:
libice-doc libsm-doc libx11-doc libxcb-doc libxt-doc openjdk-11-demo openjdk-11-source visualvm fonts-ipafont-gothic fonts-ipafont-mincho
fonts-wqy-microhei | fonts-wqy-zenhei fonts-indic
The following NEW packages will be installed:
ca-certificates-java default-jdk default-jdk-headless default-jre default-jre-headless java-common libatk-wrapper-java libatk-wrapper-java-jni libice-dev
libpthread-stubs0-dev libsm-dev libx11-dev libxau-dev libxcb1-dev libxdmcp-dev libxt-dev openjdk-11-jdk openjdk-11-jdk-headless openjdk-11-jre
openjdk-11-jre-headless x11proto-dev xorg-sgml-doctools xtrans-dev
0 upgraded, 23 newly installed, 0 to remove and 0 not upgraded.
Need to get 264 MB of archives.
After this operation, 414 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y

 

Step 5: Remove a Package

Similarly, if you want to remove any package by using package manager then you can simply do it by using apt remove or apt-get remove command. Here I am removing default JDK package by using apt-get remove default-jdk command as you can see below.

root@debian:~# apt-get remove default-jdk
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
default-jdk-headless libice-dev libpthread-stubs0-dev libsm-dev libx11-dev libxau-dev libxcb1-dev libxdmcp-dev libxt-dev openjdk-11-jdk
openjdk-11-jdk-headless x11proto-dev xorg-sgml-doctools xtrans-dev
Use 'apt autoremove' to remove them.
The following packages will be REMOVED:
default-jdk
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 6,144 B disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 136423 files and directories currently installed.)
Removing default-jdk (2:1.11-72) ...

Leave a Comment