How to get the nameserver of Linux machine

I need to find out dns of Linux machine. How can I get the nameserver of Linux machine? Is it using Google dns? How to verify?

To check DNS server information simply type the following command on Linux try any one of the following command:

Change DNS settings on Linux

cat /etc/resolv.conf
domain home.sweet
search home.sweet

A note about systemd based Linux distro

On newer Linux distro you may need to type to see details about the uplink DNS servers currently in use:

systemd-resolve --status
systemd-resolve --status | grep 'DNS Servers'
 DNS Servers:

What DNS servers am I using?

It is also possible to use the following command as well:

nmcli dev show | grep DNS

For more info see:


Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki