This error occurs when your APT sources list file contains syntax errors, typically from incorrectly quoted entries or typos. APT cannot parse the repository type and fails to update your package database.
Fixes E: Type 'deb' is not known on line X in source list /etc/apt/sources.list
E: Type 'deb' is not known on line 5 in source list /etc/apt/sources.list.d/elastic-7.x.listE: Type 'deb' is not known on line 5 in source list /etc/apt/sources.list.d/elastic-7.x.listE: Type 'deb' is not known on line X in source list /etc/apt/sources.list
APT (Advanced Package Tool) reads repository definitions from /etc/apt/sources.list and files in /etc/apt/sources.list.d/. Each line must follow a specific format starting with a type keyword like 'deb' (for binary packages) or 'deb-src' (for source packages). When APT encounters a line it doesn't recognize—often due to extra quotation marks, typos, or invalid characters—it throws this error and refuses to proceed with package updates.
Note the file path and line number from the error message. It will be either /etc/apt/sources.list or a file in /etc/apt/sources.list.d/ directory.
Example error:
E: Type 'deb' is not known on line 5 in source list /etc/apt/sources.list.d/elastic-7.x.listThis tells you the problem is on line 5 of /etc/apt/sources.list.d/elastic-7.x.list.
Use nano or your preferred text editor to open and examine the file:
sudo nano /etc/apt/sources.listOr for sources.list.d files:
sudo nano /etc/apt/sources.list.d/filename.listNavigate to the line number mentioned in the error message.
Check if the problematic line has extra quotation marks. Common mistake:
❌ Incorrect:
"deb https://repo.example.com/debian bookworm main"✓ Correct:
deb https://repo.example.com/debian bookworm mainDelete any quotation marks at the beginning or end of the line. Keep only the actual repository definition.
Verify that the line starts with 'deb' or 'deb-src', not variations like:
- 'dep' (missing 'b')
- '.deb' (has a period)
- 'Deb' (incorrect capitalization, though this may work depending on the APT version)
Fix any typos by correcting the first word of the line to exactly 'deb' or 'deb-src'.
If the line looks correct but still causes errors, it may contain invisible characters. In nano, enable display of special characters to check:
Press Ctrl+X to exit nano (if you didn't make changes), then try:
sudo cat -A /etc/apt/sources.list.d/filename.list | head -n 5Look for unusual characters like '^M' (carriage return) or Unicode markers at the start. If found, delete the entire problematic line and retype it manually.
If the line cannot be corrected or contains special characters, delete it entirely:
1. In nano, go to the problematic line
2. Press Ctrl+K to delete the entire line
3. If there are duplicate entries (both with and without quotes), keep only the correct one
Example: if you see:
"deb https://example.com stable main"
deb https://example.com stable mainDelete the first line with quotes and keep the second.
After editing:
1. Save the file: Press Ctrl+O, then Enter to confirm (in nano)
2. Exit the editor: Press Ctrl+X
3. Test by running:
sudo apt updateIf successful, you'll see 'Reading package lists... Done' without any errors. If errors persist, check the file again or refer to the advanced notes below.
If the error persists after corrections, verify the complete syntax of your sources.list entries:
Correct Format:
deb [options] <URI> <SUITE> <COMPONENT1> [<COMPONENT2> ...]
deb-src [options] <URI> <SUITE> <COMPONENT1> [<COMPONENT2> ...]Example:
deb https://deb.debian.org/debian bookworm main non-free-firmware
deb-src https://deb.debian.org/debian bookworm main non-free-firmwareOptions (in square brackets, optional):
- [arch=amd64] - Specify architecture
- [signed-by=/path/to/key.gpg] - Specify GPG key path
Additional fixes:
- Use UTF-8 encoding: file -i /etc/apt/sources.list should show UTF-8, not ISO-8859
- For problematic .list files in sources.list.d, you can safely delete the entire file if it's from a removed PPA: sudo rm /etc/apt/sources.list.d/problematic-file.list
- On some systems, use sudo apt clean after fixing to clear the cache before running sudo apt update
- If adding a third-party repository, copy the exact command from the official source rather than typing it manually