Usually when you install Ubuntu, it will ask you for your username and assign a hostname to you, such as damien@damien-laptop. This is also what you will see in your terminal. If you don’t like the hostname shown in the terminal, or for some reason that you want to change the hostname, here’re the exact steps in Ubuntu. It is very easy. Just follow along and you will be done in a minute.
1. First, open a terminal and type:
gksu gedit /etc/hostname
You should see a line stating your current hostname. For eg. damien-desktop
2. Change the hostname to something you desired. Save and close the file.
3. Back in your terminal, type:
gksu gedit /etc/hosts
4. Change the line:
127.0.1.1 damien-desktop
to
127.0.1.1 your-new-hostname
Save and close the file.
Restart the computer. Your new hostname should appear in the terminal now.
Is this article useful?
6 comments
Comments are closed.
It’s as easy as typing hostname mynewhostname from the shell/terminal window.
John Smith: your method won’t survive after a reboot.
oldname=$(cat /etc/hostname)
sudo sed -i “s/$oldname/$newname/g” /etc/hosts
if newname=$(zenity –entry –text=”Enter new hostname:”); then
oldname=$(cat /etc/hostname)
sudo sed -i “s/$oldname/$newname/g” /etc/hosts
read -p “A reboot is required to apply the changes, go down now? (Y,N):” hostnamechangeranswer
case $hostnamechangeranswer in
y|Y)
sudo reboot;;
n|N)
exit 0;;
esac
fi
hi i had just purchased this laptop from a old roommate who had forgotten his passwords and moved. i successfully reset the password BUT i am having trouble changing the settings. especially the terminal name. this is also the FIRST time ive ever used linux ubuntu. right now i have half of the terminal name as i want it but the other half wont change with everything ive tried…. for example it reads jarrod@xxxxxxxxx and i want it to say sheri@xxxxxxxx . i cant get the name jarrod off . how do i do it?
I believe you are logging in with the username “jarrod”. Create another user account of the name “sheri”. Once you log in, you should see sheri@xxxxxxxx in the terminal.