This error occurs when APT encounters a syntax error in one of your repository source files. It typically happens when a repository entry is split across multiple lines, missing required fields, or contains formatting errors. The fix involves locating the problematic entry and correcting its format.
The 'Malformed entry in list file' error indicates that APT's parser encountered a repository source line that doesn't conform to the expected format. Each line in /etc/apt/sources.list or files in /etc/apt/sources.list.d/ must follow the strict format: `deb [options] URL distribution component [component2 ...]`. When this structure is violated—whether by line breaks in the middle of an entry, missing spaces, typos in the URL, or missing distribution codenames—APT rejects the entire sources.list.d file and cannot proceed with updates or installations.
The error message tells you the problematic file. For example:
E: Malformed entry 1 in list file /etc/apt/sources.list.d/docker.list (Suite)This tells you the problem is in /etc/apt/sources.list.d/docker.list on line 1. Make a note of this path.
Open the file to see what's causing the issue. For the example above:
cat /etc/apt/sources.list.d/docker.listOr to view it with a text editor:
sudo nano /etc/apt/sources.list.d/docker.listA valid entry must follow this format (all on one line):
deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stableBreak down:
- deb - indicates binary packages (or deb-src for source packages)
- [arch=amd64] - optional: architecture specifier
- https://download.docker.com/linux/ubuntu - the repository URL
- focal - the distribution codename (your Ubuntu/Debian version)
- stable - the component/channel name
Common mistakes to check:
- Is the entry split across 2+ lines? It must be on ONE line
- Is there a space between the URL and distribution name?
- Is the distribution codename present (focal, jammy, bionic, xenial, etc.)?
- Are there any trailing spaces or special characters?
If you need to fix the entry, edit it with:
sudo nano /etc/apt/sources.list.d/docker.listMake sure:
1. Each repository is on a single line
2. All required parts are present: deb URL distribution component
3. Spaces separate each part correctly
4. The distribution codename matches your system (run lsb_release -sc to verify)
Save and exit (Ctrl+X, then Y, then Enter in nano).
If the repository file is old or no longer needed, you can safely delete it:
sudo rm /etc/apt/sources.list.d/docker.listThen verify the error is gone with:
sudo apt updateOnce the problematic entry is fixed or removed, test that APT can now read all sources:
sudo apt updateThis command should complete without the 'Malformed entry' error. If you see the error on a different file, repeat these steps for that file.
When manually adding repositories with add-apt-repository, be aware that some PPAs wrap their deb line automatically. If you're using add-apt-repository 'deb URL distribution component', make sure you don't also manually edit the file—the command should handle formatting. For system administrators managing many sources, consider using configuration management tools like Ansible or Puppet to ensure consistent, correctly-formatted repository configurations across machines. The distribution codename is critical and must match your OS: use lsb_release -sc to print your exact codename (focal, jammy, bionic, etc.). Debian users should use their Debian codename (bullseye, bookworm, sid, etc.) instead.
E: Could not connect to proxy server
Could not connect to proxy server
E: Package 'package:i386' has no installation candidate
How to fix "Package package:i386 has no installation candidate" in apt
E: The value 'value' is invalid for APT::Default-Release
How to fix invalid APT::Default-Release value in APT
dpkg: error: unable to create new file 'path': Permission denied
How to fix dpkg permission denied errors in APT
subprocess installed post-removal script returned error exit status 1
How to fix "subprocess installed post-removal script returned error exit status 1" in APT