How to add line to system configuration file with sudo?

Solution 1:

sudo /bin/sh -c 'echo "nameserver 192.168.1.6" >> /etc/resolv.conf'

Solution 2:

echo "nameserver 192.168.1.6" | sudo tee -a /etc/resolv.conf