- oldname=$(cat /etc/hostname)
- #newname=$1
- # You'll need to test that the new name exists here, and exit gracefully if it does not.
- echo "Please Enter a new hostname"
- read newname
- echo $newname > /etc/hostname #hostname "$newname"
- echo "Hostname changed from $oldname to $newname"
- cat /etc/hosts | sed s/"$oldname"/"$newname"/ > /tmp/newhosts
- mv /tmp/newhosts /etc/hosts
- echo "The /etc/hosts file has been changed"
- echo "Don't forget to logout and log back in before your X server crashes..."
SHARE
TWEET
Untitled
a guest
Feb 15th, 2015
164
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
RAW Paste Data
