Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/bash
old=`hostname`
new="$1"
read -p "Change hostname from \"$old\" to \"$new\"? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
sudo true
set -v
sudo hostnamectl set-hostname $new
sudo sed -i"" "s#$old#$new#" /etc/hosts
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.