Setting the hostname


(Geoffrey Challen) #1

If you are running Ubuntu and you did not use our Vagrantfile, you may notice that you terminal prompt displays an enormous hostname in front of your prompt, push it all the way off the right. Like this:

user@user-Lenovo-ideapad-V700-14ISK:~$

This is irritating because it pushes your prompt all the way to the right part of the terminal and wastes a lot of space. There are two ways to fix this:

  1. Change your PS1 environment variable in ~/.bashrc. This is what sets up what the prompt looks like, and \h expands to the system hostname. Feel free to Google around for custom prompts, but a full description of bash prompt customization is way out of the scope of this post.
  2. Change your system hostname. To do this temporarily use the hostname command; to do this permanent change /etc/hostname. On systems that serve entirely as network clients (rather than servers), changing this to whatever you want is safe. (Changing it on servers can cause unexpected consequences.)