How to fix "The list of sources could not be read" error on Debian

Endrit Qerreti

Endrit Qerreti

In this tutorial, you will learn how to fix the error "E: The list of sources could not be read" on Debian

This error indicates that one or multiple sources are not readable by the system, thus they can't be used to update your system.

This issue happens when you are adding or removing sources from the sources.list file, and you accidentally make sources unreadable.

You may be asking how does this happen exactly? Well, sources are URLs, and if you add a character or space somewhere in the URL, that would be enough to break that source.

In our case we were trying to perform a simple system update, with the command

sudo apt-get update

And we got two errors as below

" E: Type 'd' is not known on line 11 in source list /etc/apt/sources.list"

"E: The list of sources could not be read"

Now based on the errors that we got, it sounds like something happened to the line 11. So, the first thing that we are going to do, is to check the sources.list file and see if we can identify the problem.

Let's cat the sources.list file

cat /etc/apt/sources.list

We are using the cat command to view the content of the sources.list file, because we still don't know yet what happened to this file, so we can't open it directly with a text editor and fix it. The file is already broken, and we don't need to break it more.

And this is how the sources.list should look like

Now since we already know that the issue is caused by the line 11, we need to enable lines when using the cat command in order to easily identify it. To do this, we need to use the --number option

cat --number /etc/apt/sources.list

As we can see in the image above, the issue is caused by a blank space between d and eb word

d eb https://deb.debian.org/debian/ bookworm-updates main non-free-firmware

Let's now fix this. First let's open sources.list with nano

sudo nano /etc/apt/sources.list

Next, we are going to delete the blank space that is causing this issue. We also need to enable line numbers for nano so we know which is the line 11

To enable line numbering on nano, you need press ALT + SHIFT + 3 after the sources file has been opened with nano, so the sources file should look like this

Now that the blank space is removed, we need to save changes by pressing CTRL + X, and then confirming with Y.

Finally, press enter to write the changes to sources.list file

Once sources.list is saved, we need to check if the issue is fixed. So, let's perform a system update by using the apt update command

sudo apt update

And..yay we can see that the error is gone, and we can update our system now.

Conclusion

In this tutorial, you learned how to fix the error " E: The list of sources could not be read" on Debian.