Skip to content

Instantly share code, notes, and snippets.

@jbdatko
Created August 29, 2014 18:03
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 jbdatko/d7fd5f4232db99f85e00 to your computer and use it in GitHub Desktop.
Save jbdatko/d7fd5f4232db99f85e00 to your computer and use it in GitHub Desktop.
Script to change hostnames on debian systems
#!/bin/bash
if [[ "$#" -ne 1 ]]; then
echo "$0 usage: newhostname (run as root)"
exit 1
fi
name=$(hostname)
hostname $1
sed -i "s/$name/$1/" /etc/hosts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment