daily pastebin goal
45%
SHARE
TWEET

Untitled

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