Last updated on October 16th, 2023 at 09:42 am.
When you install a new Debian instance, you may not have any package repository sources in your default Debian source file. Here is how to populate it .
Open the sources file using apt:
sudo apt edit-sources
If it is the first time ever, running this command, you will need to select an editor to use. Nano is probably number one, so type 1 and press enter to use it as the text editor for editing the source file. Or choose any other editor of your choice.
If the file is empty, enter the following default list for Debian 12 (code-named “Bookworm”):
deb https://deb.debian.org/debian bookworm main non-free-firmware #deb-src http://deb.debian.org/debian bookworm main non-free-firmware deb https://deb.debian.org/debian-security/ bookworm-security main non-free-firmware #deb-src http://deb.debian.org/debian-security/ bookworm-security main non-free-firmware deb https://deb.debian.org/debian bookworm-updates main non-free-firmware #deb-src http://deb.debian.org/debian bookworm-updates main non-free-firmware
In Nano press CTRL X , press Y to accept changes . Then enter.
Then run the following to update the cache with the new source file:
sudo apt update
There you go, you can now install applications from the Debian repo.
How to Edit Debian and Ubuntu Sources List – A Quick Guide
Welcome to this quick video on how to edit the sources list for Debian and Ubuntu, as well as for related Debian-based distros. Watch the video for a quick step by step guide.
1. Editing the Sources List
To start, you’ll need to open the Debian sources list for editing. The command you’ll use is
sudo apt edit-sources. When you execute this command, you might be prompted to choose an editor. You can pick either Nano or Vim, depending on your preference and the one installed on your system.
sudo apt edit-sources
2. Editing in Nano or Vim
In my case (in the video above), it opened in Nano right away. In your case, you might be asked to select an editor. If that happens, press ‘1’ for Nano or ‘2’ for Vim. Your chosen editor will open with the sources list.
Here, you can see the sources list I’m working with, named “The Bookworm sources list.” You can modify this list by adding your own sources. This is particularly useful when you’re setting up a new Debian distribution. You can find a sample in the video description.
3. Saving Changes
If you’re using Nano, you can save your changes by pressing
Ctrl + X and then ‘Y’ to confirm.
On Vim, you can use
Shift + ZZ or
:wq! to save and exit.
4. Vim for Advanced Users
If you’re working on a desktop, consider installing Vim with
sudo apt install vim. Vim allows you to use commands like
Shift + ZZ to save or
Shift + Z + Q to close without saving. In my example, I’m using Nano, and I’ll simply exit by pressing
Ctrl + X since I didn’t make any changes.
5. Navigating to Source Files
Now, if you need to work with other source files, you can find them under the
/etc directory. Simply enter
LS to list the contents. You’ll spot the
apt directory there. To proceed, press ‘Tab’ twice to see what’s inside. Use the
Tab key to autocomplete ‘sources list- D’. Press ‘Enter’, and you’ll access the source files for other applications.
6. Making Corrections
If you encounter issues with your system and suspect that they’re related to the source files, you can use the
rm command to remove the files causing problems.
sudo rm /etc/apt/sources.list.d/filename
And that’s it! Editing the sources list for Debian, Ubuntu, and Debian-based OSes. With the
sudo apt edit-sources command, you can easily manage your sources and keep your system running smoothly.
I hope this guide has been helpful. If you have any questions or need further assistance, feel free to ask. Until next time!