Sometimes you will need to change hostname in some Distro Linux like CentOS or Ubuntu and you are considering what is the easy way to do that. So i will help you to set hostname CentOS 7/6 and Ubuntu/Debian with below instructions. However, you know what is hostname value in Linux right? An alias name to indicate your system to easily manage.
1. Change hostname on CentOS and Ubuntu
+ CentOS/RHEL/Fedora 6
– For example, the value of hostname i will use is : host.cuongquach.com
– You just need to edit this file : ‘/etc/sysconfig/network‘
# vi /etc/sysconfig/network HOSTNAME=host.cuongquach.com # hostname "host.cuongquach.com"
+ CentOS/RHEL/Fedora 7
– Edit this file: ‘/etc/hostname‘
# vi /etc/hostname HOSTNAME=host.cuongquach.com # hostname "host.cuongquach.com"
+ Ubuntu/Debian
# echo "host.cuongquach.com" > /etc/hostname # hostname -F /etc/hostname
2. Change info in file hosts then reboot
– Edit DNS hosts to match new hostname for translation IP-Hostname.
# vi /etc/hosts 127.0.0.1 host.cuongquach.com
– Reboot your system to apply new change.
# reboot
3. Checking
– Run command “hostname” and you will see your hostname.
# hostname host.cuongquach.com
See, you can do it by yourself for changing or setting new hostname in Linux.