Change Linux hostname [Ubuntu]
- Vinicius Souza
- Linux
- December 9, 2019
I think everyone has already installed a virtual machine or hired a Cloud and come across the default name in the machine’s Hostname, generally it is the OS used. Or you entered a name and want to change it, but forgot how. In this post we will show TWO WAYS you can change your hostname easily.
Method number 1
1 - Place the desired name in the hosts file
vim /etc/hosts
2 - Place the desired name in the hostname file
vim /etc/hostname
3 - Place the new name directly into memory
echo "NAME_YOU_DESIDRE" > /proc/sys/kernel/hostname
4 - Log off and log back on or run “bash
Look our new hostname:
Method number 2
1 - Check if you have hostnamectl in your distribution
hostnamectl status
2 - Enter the name you want, in my example I used “tutorial”
hostnamectl set-hostname tutorial
3 - Log off and log back on or run “bash”
Let’s see the hostname:
That’s it! From this tutorial we learned two really cool ways to change your machine’s hostname. The tutorial was made in Ubuntu, but it should work in your distribution.
Finally, thank you for reading and we hope this post has helped you in some way! If you have any questions, please contact us at Telegram , Facebook or Instagram ! See more posts on IronLinux !