PDA

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



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

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


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

thanx in advance:popcorn:

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

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

Sukarn
May 27th, 2008, 02:13 PM
it puts "nameserver 4.2.2.4" 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 4.2.2.4 as a DNS server.

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

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

Sukarn
May 27th, 2008, 02:27 PM
It should also print "nameserver 4.2.2.4" 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 4.2.2.4" 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

sdennie
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.