3

This question is an obvious updated version of How do I remove a malformed line from my sources.list?. In Ubuntu 24.04 and later Ubuntu software sources have been moved to /etc/apt/sources.list.d/ubuntu.sources.

As a starting point here is what the default ubuntu.sources file looks like in Ubuntu 24.04.

Types: deb
URIs: http://archive.ubuntu.com/ubuntu/
Suites: noble noble-updates noble-backports
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

Types: deb URIs: http://security.ubuntu.com/ubuntu/ Suites: noble-security Components: main restricted universe multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

karel
  • 122,292
  • 133
  • 301
  • 332

1 Answers1

1

These instructions are compatible with Ubuntu 24.04 and later in which software sources are located in separate files that are located under the /etc/apt/sources.list.d/ directory.

  1. Identify the file which contains the malformed line.

    The error message you encounter will typically point you to the specific file containing the malformed line. It might look something like this.

    Malformed entry 1 in list file /etc/apt/sources.list.d/additional-repo.list
    

    In this example /etc/apt/sources.list.d/additional-repo.list is the file with the line that is referred to by the malformed line error message.

  2. Back up the file before making changes with cp /etc/apt/sources.list.d/<filename> /etc/apt/sources.list.d/<filename>.bak

  3. Open the file for editing with root privileges.

    Use a text editor that runs in the terminal like nano to edit the file. Replace <filename> with the file identified in step 1 in the following command.

    sudo nano /etc/apt/sources.list.d/<filename>
    
  4. Locate and remove the malformed line.

    • In the opened file look for lines that appear malformed compared to the standard format.

    • Here are examples of correctly formatted lines for reference:

      # Comment line (any line that starts with #)  
      deb http://archive.ubuntu.com/ubuntu focal main restricted universe
      deb-src http://archive.ubuntu.com/ubuntu focal main restricted universe
      
    • Anything that doesn't follow this format is likely to be either a third-party software source or else it's incorrect.

    • Use the arrow keys to navigate and position the cursor on the malformed line and insert a # character at the beginning of the line to turn it into a comment.

  5. Save the file being edited and exit from nano.

    • Press the keyboard combination Ctrl+O and after that press Enter to save the file being edited.
    • Press the keyboard combination Ctrl+X to exit nano.
  6. Update the package lists by running sudo apt update

karel
  • 122,292
  • 133
  • 301
  • 332