2

I'd like to begin by stating that I am a new user and would like to ask that you all go easy on me. I've read other post with this problem, except my issue is slightly different and the solutions offered didn't effectuate a solution in my case, so here it is...

When I attempt to input sudo apt-get update, I encounter the following error message...

E: Malformed entry 57 in list file /etc/apt/sources.list(Component)
E: The list of sources could not be read. 

After reading the responses to similar issues, I tried sudo -H gedit /etc/apt/sources.list

and that command opened up my sources list:

# deb http://us.archive.ubuntu.com/ubuntu/bionic main restricted
# deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
# deb http://security.ubuntu.com/ubuntu bionic-security main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://us.archive.ubuntu.com/ubuntu/ bionic main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ bionic universe main restricted multiverse
## Major bug fix updates produced after the final release of the
## distribution.
deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-updates universe main restricted multiverse
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://us.archive.ubuntu.com/ubuntu/ bionic universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic universe
deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-updates universe
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
## team, and may not be under a free licence. Please satisfy yourself as to 
## your rights to use the software. Also, please note that software in 
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://us.archive.ubuntu.com/ubuntu/ bionic multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic multiverse
deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-updates multiverse
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://us.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
deb http://archive.canonical.com/ubuntu bionic partner
deb-src http://archive.canonical.com/ubuntu bionic partner
deb http://security.ubuntu.com/ubuntu bionic-security main restricted
deb-src http://security.ubuntu.com/ubuntu bionic-security universe main restricted multiverse
deb http://security.ubuntu.com/ubuntu bionic-security universe
# deb-src http://security.ubuntu.com/ubuntu bionic-security universe
deb http://security.ubuntu.com/ubuntu bionic-security multiverse
# deb-src http://security.ubuntu.com/ubuntu bionic-security multiverse
deb https://dl.winehq.org/wine-builds/ubuntu/ bionic main
# deb-src https://dl.winehq.org/wine-builds/ubuntu/ bionic main
deb https://dl.winehq.org/wine-builds/ubuntu/ cosmicmain
# deb-src https://dl.winehq.org/wine-builds/ubuntu/ cosmicmain
# deb-src https://dl.winehq.org/wine-builds/ubuntu/ cosmicmain
deb https://dl.winehq.org/wine-builds/ubuntu/ bionicmain
# deb-src https://dl.winehq.org/wine-builds/ubuntu/ bionicmain
deb https://dl.winehq.org/wine-builds/ubuntu/ xenialmain
# deb-src https://dl.winehq.org/wine-builds/ubuntu/ xenialmain
deb https://dl.winehq.org/wine-builds/ubuntu/ trustymain
# deb-src https://dl.winehq.org/wine-builds/ubuntu/ trustymain

I read that running commands that remove lines from your sources list can wreck your list file entirely, so I am hesitant to do that and I do not know how to uncomment a line.

Also, in order to circumvent the 8 link limitation imposed on members with less that 10 reputation points. I was forced to add spaces in the links of my sources list to avoid it being registered as a link, in order to be able to post this question. So please ignore the extra spaces that will be represented as an underscore in the following example...

Ex: http_://us.archive.ubunt....etc etc.

Can anyone please assist, Thanks.

terdon
  • 100,812

2 Answers2

1

You do indeed have a malformed line. Many, actually, but including the specific one the error complained about. I have saved your file as file, and can see that line 57 is:

$ awk NR==57 file
# deb-src https://dl.winehq.org/wine-builds/ubuntu/ trustymain

You want trusty main and not trustymain. I don't know how that got there, but it's easy to fix. Just run this:

sudo sed -i.bak -E 's/([cly])main/\1 main/' /etc/apt/sources.list

This will do the following:

  1. It will create a backup of your existing sourcce.list called /etc/apt/sources.list.bak so you don't need to worry about breaking it.
  2. It will replace all cases where you have a c, an l, or a y immediately before the word main with itself (whichever of c, y or l was found) followed by a space.

    You need this because you have these lines:

    $ grep -P '^[^#].*\Smain' file 
    deb https://dl.winehq.org/wine-builds/ubuntu/ cosmicmain
    deb https://dl.winehq.org/wine-builds/ubuntu/ bionicmain
    deb https://dl.winehq.org/wine-builds/ubuntu/ xenialmain
    deb https://dl.winehq.org/wine-builds/ubuntu/ trustymain
    

    And they need to be changed to:

    $ grep -P '^[^#].*\Smain' file | sed -E 's/([cly])main/\1 main/' 
    deb https://dl.winehq.org/wine-builds/ubuntu/ cosmic main
    deb https://dl.winehq.org/wine-builds/ubuntu/ bionic main
    deb https://dl.winehq.org/wine-builds/ubuntu/ xenial main
    deb https://dl.winehq.org/wine-builds/ubuntu/ trusty main
    

    Which is precisely what this command will do.

terdon
  • 100,812
  • I don't think OP needs all bionic,xenial etc. And it's not quite clear what is really there. – Pilot6 Sep 12 '19 at 17:36
  • Thank you kindly for your help! Error message is gone and updates are now working – The_Official_Mundo Sep 12 '19 at 19:08
  • 1
    @Pilot6 I agree the OP probably doesn't, but that's not my call to make :) in any case, it should be safe since the older repos should have older versions and be ignored. As for the contents, since the line number matched, I felt confident enough that it would work. – terdon Sep 12 '19 at 19:13
0

Check this one:

# deb http://us.archive.ubuntu.com/ubuntu/bionic main restricted
# deb http: //us.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
# deb http://security.ubuntu.com/ubuntu bionic-security main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://us.archive.ubuntu.com/ubuntu/ bionic main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ bionic universe main restricted multiverse
## Major bug fix updates produced after the final release of the
## distribution.
deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-updates universe main restricted multiverse
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://us.archive.ubuntu.com/ubuntu/ bionic universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic universe
deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-updates universe
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
## team, and may not be under a free licence. Please satisfy yourself as to 
## your rights to use the software. Also, please note that software in 
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://us.archive.ubuntu.com/ubuntu/ bionic multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic multiverse
deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-updates multiverse
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://us.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
deb http://archive.canonical.com/ubuntu bionic partner
deb-src http://archive.canonical.com/ubuntu bionic partner
deb http://security.ubuntu.com/ubuntu bionic-security main restricted
deb-src http://security.ubuntu.com/ubuntu bionic-security universe main restricted multiverse
deb http://security.ubuntu.com/ubuntu bionic-security universe
# deb-src http://security.ubuntu.com/ubuntu bionic-security universe
deb http://security.ubuntu.com/ubuntu bionic-security multiverse
# deb-src http://security.ubuntu.com/ubuntu bionic-security multiverse
deb https://dl.winehq.org/wine-builds/ubuntu/ bionic main
# deb-src https://dl.winehq.org/wine-builds/ubuntu/ bionic main
deb https://dl.winehq.org/wine-builds/ubuntu/ cosmic main
# deb-src https://dl.winehq.org/wine-builds/ubuntu/ cosmic main
# deb-src https://dl.winehq.org/wine-builds/ubuntu/ cosmic main
# deb-src https://dl.winehq.org/wine-builds/ubuntu/ bionic main
deb https://dl.winehq.org/wine-builds/ubuntu/ xenial main
# deb-src https://dl.winehq.org/wine-builds/ubuntu/ xenial main
deb https://dl.winehq.org/wine-builds/ubuntu/ trusty main
# deb-src https://dl.winehq.org/wine-builds/ubuntu/ trusty main

You didn't have any spaces between cosmicmain -> cosmic main And lines 47 and 52 were basically the same

Also, I wouldn't suggest having different versions of the distro as you can get in trouble