1

This error is showing up when using sudo apt get update:

E: Syntax error /etc/apt/apt.conf:2: Extra junk at end of file

error message from terminal

Lorenz Keel
  • 8,905
  • 4
    Your command is wrong. The correct one is sudo apt-get update, or sudo apt update. run the correct command and check if the problem is still present. – Lorenz Keel Jun 02 '22 at 10:22
  • 1
    If the problem persists, edit your question with the output of cat /etc/apt/apt.conf: you can fix the error only if you check the file content (as the error suggests to you) – Lorenz Keel Jun 02 '22 at 10:45
  • this is the content of the file apt.conf

    Acquire::http::proxy “http://<proxy_server>:/”;

    – Anmol Chooudhary Jun 02 '22 at 13:27
  • 1
    @AnmolChooudhary please add the output of cat -A /etc/apt/apt.conf to your question using the [edit] button – steeldriver Jun 02 '22 at 13:51

1 Answers1

1

In a comment, you wrote that the content of the file is:

Acquire::http::proxy “http://<proxy_server>:<port>/”;

In this case, the content of your apt.conf is not well-formed. If you need it to use apt behind a proxy, <proxy_server> and <port> should be replaced by the real values of proxy server and port.

Just as an example, you can check the question here to see how a proper apt.conf file is written.

Therefore, you have two possible solutions:

  1. Make a backup of the file by sudo mv /etc/apt/apt.conf /etc/apt/apt.conf.bak, then check if sudo apt-get update works (this may work only if you don't really need to be behind a proxy).
  2. Use sudo -H gedit /etc/apt/apt.conf and edit the file replacing the two placeholders with correct proxy server and port.
Lorenz Keel
  • 8,905