E: Type 'sudo' is not known on line 1 in source list /etc/apt/sources.list.d/ppa.list
means a list file contains something that is not a repository line. In the test it was
a pasted command, sudo add-apt-repository ppa:deadsnakes/ppa. Remove that
file or line, and run the command in the shell if that is what you meant to do.
The word in quotes is the first word of the bad line. The working lines in these tests
all started with deb, so a 'sudo' there is a sign that a
command ended up in the file.
The error
$ echo 'sudo add-apt-repository ppa:deadsnakes/ppa' > /etc/apt/sources.list.d/ppa.list
exit code: 0
$ apt-get update
E: Type 'sudo' is not known on line 1 in source list /etc/apt/sources.list.d/ppa.list
E: The list of sources could not be read.
exit code: 100
A bare PPA name in the file gave a different message for the same kind of mistake:
$ echo 'ppa:deadsnakes/ppa' > /etc/apt/sources.list.d/ppa.list
exit code: 0
$ apt-get update
E: Malformed line 1 in source list /etc/apt/sources.list.d/ppa.list (type)
E: The list of sources could not be read.
exit code: 100
Why it happens
A line in a .list file starts with a type; every working line in these
tests used deb. apt read the first word of the line as the type. With the pasted
command that word was sudo, a word apt does not know, so it named it. With
ppa:deadsnakes/ppa the line had a single word, and apt reported the line
as malformed at the (type) part instead. In both runs apt printed no
Hit: or Get: line, only the two E: lines, and
returned 100.
Both messages end with the same second line, E: The list of sources could not be
read., and both name the file and the line number. That pair is what to look
for: the first line tells you which file and line to open, the second that apt did
nothing else until the file is fixed.
The fix
$ mv /etc/apt/sources.list.d/ppa.list /root/ppa.list.off
exit code: 0
$ apt-get update
Hit:1 http://archive.ubuntu.com/ubuntu noble InRelease
Hit:2 http://security.ubuntu.com/ubuntu noble-security InRelease
Hit:3 http://archive.ubuntu.com/ubuntu noble-updates InRelease
Hit:4 http://archive.ubuntu.com/ubuntu noble-backports InRelease
Reading package lists...
exit code: 0
With the bad file out of /etc/apt/sources.list.d/ the update ran again
and returned 0. The file was moved to /root so it could be inspected.
If the file holds good lines as well, delete only the bad
line, the one the message numbers. If you wanted the PPA, the command belongs at the
shell prompt, not in a list file (adding this PPA was not tested here); if
add-apt-repository is missing, the
add-apt-repository post
shows the package to install.
How it was reproduced
The capture was made in an ubuntu:24.04 container (Ubuntu 24.04.5 LTS,
apt 2.8.3) on Docker Engine 29.9.3, standing in for Ubuntu in WSL. As root, a file
ppa.list was written first with the bare PPA name and then with the whole
command, apt-get update was run after each, and the file was moved out
of the folder before the last update. No PPA was added or contacted.
Frequently asked
- How do I fix 'E: Type is not known on line 1 in source list'?
- Open the file the message names and remove the line that does not start with deb. In the test the line was a pasted sudo add-apt-repository command; moving the file out of sources.list.d made apt-get update return 0.
- Can I put ppa: in a sources.list file?
- Not as it is. In the test a file holding ppa:deadsnakes/ppa gave Malformed line 1 (type) and The list of sources could not be read.
- Why does apt name 'sudo' as the type?
- apt read the first word of the line as the repository type. The pasted command started with sudo, so that is the word it reported.
More decoded errors in the Fixes category. A
deb line with a missing part gives
Malformed entry (Component).