How To Set Google DNS On Your Linux Computer (Terminal)

Share This!

Linux (Terminal)

This page will guide you through the setup process on a Linux computer using the built-in terminal, which is available on almost all versions and distributions of Linux.

If you are using Ubuntu and would like to set Google DNS via its Unity desktop environment, kindly refer our instructions here:


How To Set Google DNS On Your Linux Computer (Ubuntu)

  1. Go to your Terminal and type in sudo bash . This will give you super user privilege.

  2. Once you have the super user (administrator) access, type in the command below to back up your network configuration file.

    cp /etc/resolv.conf /etc/resolv.orig


  3. Next, type in the command below to remove the resolv.conf file.

    rm /etc/resolv.conf


  4. Now, type in the command below one at a time.

    echo “nameserver” > /etc/resolv.conf


    echo “nameserver” >> /etc/resolv.conf


  5. Finally, type in the command below.

    cat /etc/resolv.conf

    If the set up was successful , it will display the Google DNS that you’ve specified earlier.


If you wish to set a custom DNS on a different device or system, please refer to our article here:

How to Set Google DNS on your device / system

If you have any problems or need further assistance, please email us at [email protected]. We’ll get back to you as soon as possible and try to help.