Skip to content

Instantly share code, notes, and snippets.

@beginor
Created June 22, 2017 08:35
Show Gist options
  • Select an option

  • Save beginor/3b8e2eab0fbb41757213cc5b50f96dae to your computer and use it in GitHub Desktop.

Select an option

Save beginor/3b8e2eab0fbb41757213cc5b50f96dae to your computer and use it in GitHub Desktop.
Update host through shell.
# update hosts
echo "Start update hosts"
echo "Create a new host file"
touch hosts
echo "Done!"
echo "Update AD block hosts ..."
curl https://raw.githubusercontent.com/vokins/yhosts/master/hosts >> hosts
echo "Done!"
echo "Update Google hosts ..."
curl https://raw.githubusercontent.com/sy618/hosts/master/p >> hosts
echo "Done!"
echo "Update Youtube hosts ..."
curl https://raw.githubusercontent.com/sy618/hosts/master/y >> hosts
echo "Done!"
echo "Update FQ hosts ..."
curl https://raw.githubusercontent.com/racaljk/hosts/master/hosts >> hosts
echo "Done!"
echo "Start update your host file, please input your password:"
sudo mv /etc/hosts /etc/hosts_$(date +%Y%m%d)
echo "Current host is backup to /etc/hosts_$(date +%Y%m%d)"
sudo mv hosts /etc/hosts
echo "Host file update completed."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment