View Full Version : [ubuntu] anyone knows what this command does?

Sec Expert
May 27th, 2008, 02:08 PM
is there anyone who knows what this command does?:

echo "nameserver" | sudo tee /etc/resolv.conf

is resolv.conf a file in my OS how can I reach that?

thanx in advance:popcorn:

May 27th, 2008, 02:10 PM
It looks like it will add "nameserver" to the file at /etc/resolv.conf

You can view the file by using
cat /etc/resolv.conf

May 27th, 2008, 02:13 PM
it puts "nameserver" into the file "/etc/resolv.conf"

/etc/resolv.conf contains list of DNS servers, which are the servers that are contacted when you try to visit a website, to translate the website address into DNS address. For example, when you type www.ubuntu.com, a DNS server will be contacted and asked what IP address www.ubuntu.com translates to. The DNS server replies with an IP address, and then your computer visits that IP address.

What the above command is doing is adding as a DNS server.

DNS servers are specified in /etc/resolv.conf by saying "nameserver [IP address of DNS server]" on a new line.

May 27th, 2008, 02:24 PM
It should also print "nameserver" to your screen! ;)

May 27th, 2008, 02:27 PM
It should also print "nameserver" to your screen! ;)

Yes, its supposed to do that.

By the way, I forgot to mention earlier that the command will wipe the entire contents of /etc/resolv.conf and replace them with "nameserver" because it uses tee. It could have used cat instead to catenate the nameserver line to the end of the file, but because it uses tee, it will just replace /etc/resolv.conf

May 27th, 2008, 02:31 PM
Depending on who suggested the command, that may be the goal of it (the /etc/resolv.conf clobber). The stdout output of the tee might just be for user confirmation.