How to fix “Malformed entry in /etc/apt/sources.list” error?

Recently I was installing Wine on my Ubuntu system while adding the Wine repository it displayed an error i.e. “E: Malformed entry 58 in list file /etc/apt/sources.list (Component)” you can see this in the image below.

malformed error

Here I will explain why this error is caused and what are possible solutions to this.

Why this error is caused?

This error occurs because of some problem with the given line number. The possible reasons could be –

  • You place / (slash) incorrectly in the URL.
  • If you have copied the repository URL it might be caused by some space, it is recommended to delete each space and then save the file
  • You added an incorrect URL.

There could be some other reasons but first, you should check and correct the above things.

The solution to this problem

Follow the given steps to solve this issue –

1. To fix this issue first run the given command and identify the line which is causing the problem.

sudo cat -n /etc/apt/source.list

This will display the given output in your terminal.

display source list file

2. Open the /etc/apt/sources.list using a text editor and remove that line or comment it by placing a # at the starting of the line. Use the given command to open it.

sudo nano /etc/apt/sources.list

3. Now use the given command to refresh the package repository

sudo apt update && sudo apt upgrade -y

4. Try the command once again to add the wine repository now it should work perfectly.

install software properties command

As you can see in the given image now the same command is working perfectly.

Conclusion

I hope this fixes your issue but if you are still facing it then write us in the comments below.

6 thoughts on “How to fix “Malformed entry in /etc/apt/sources.list” error?”

  1. lsb_release-cs: command not found
    E: Malformed entry 50 in list file /etc/apt/sources.list (Component)
    E: The list of sources could not be read.

    Reply
  2. Hi. Your manual got me farther than anything before.
    But in the end it didn’t do it for me. Same error message.
    I thought I might need to save it in the text editor, but it’s a read-only, I’m told that I don’t have permission.
    Meaning I don’t get to update/upgrade.

    Reply
    • p.s. so the problem of the text editor being a read-only solved itself. Literally. Today I thought I’d try the insanity-defining thing and try the same once more, even though it had not yielded in any results the times before. Today I could edit. Even though I’d had it sit for a couple days, doing nothing about it.
      Apart from that it was your tutorial here that saved the situation. Clear, simple and to the point. Thank you, and I genuinely wish you a great week 🙂

      Reply

Leave a Comment