Unable to use sudo apt-get <command name> in ubuntu 18.04

You are very likely to have followed the Cloud SDK install instructions to the letter. Some steps are alternative (ie, you do one or the other).

As a result, your /etc/apt/sources.list.d/google-cloud-sdk.list will have a duplicate entry:

deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt  cloud-sdk main 
deb https://packages.cloud.google.com/apt cloud-sdk main

As you can see, both lines are the same except that one specifies a keyring file and the other does not (so it uses the default). There is your conflict.

You shall remove the line containing the 'signed-by' and you would be good to go.


I had the same problem. I think the issue is you are missing this file: cloud.google.gpg in /usr/share/keyrings/

To fix it you could do:

  1. Remove google-cloud-sdk so you can use apt-get again:

    cd /etc/apt/sources.list.d

    sudo rm google-cloud-sdk.list

  2. Install curl (in case you dont have it):

    sudo apt-get install curl

  3. Copy the key:

    curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -

  4. Add source to list again:

    echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list

    echo "deb https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list

  5. Install the sdk again:

    sudo apt-get update

    sudo apt-get install google-cloud-sdk

I think this is what worked for me but I am also not very exerienced so please if someone can provide further detail, that would be ideal.

Hope it works :)