Skip to content

Instantly share code, notes, and snippets.

@donilan
Last active May 11, 2020 01:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save donilan/67d38d263c21702447729d9084e51198 to your computer and use it in GitHub Desktop.
Save donilan/67d38d263c21702447729d9084e51198 to your computer and use it in GitHub Desktop.
Update hostname, before execute this script, please export NEW_HOSTNAME=your.new.domain
#!/usr/bin/env bash
sudo hostname $NEW_HOSTNAME
hostname | sudo tee /etc/hostname
sudo sed -i -e "s/ $(hostname)//g" -e "/127.0.0.1/s/\$/ $(hostname)/" /etc/hosts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment