First, what is the correct way to change the hostname in Linux ? I followed some steps on the internet and sometimes it does not take effect. Besides, the new hostname does not appear when I ping my PC from another one on the same LAN. So how to change the host name and make it appear on the LAN ?
Asked
Active
Viewed 466 times
-1
-
3When asking on the SE sites, you need to tell us what you did and how it failed. "I followed some steps on the internet and sometimes it does not take effect." is really not very useful. Please [edit] your question, tell us what you did and exactly how it failed and also explain how your LAN is set up. Do you have a local DNS server that can resolve IPs to hostnames? – terdon Mar 05 '15 at 15:07
1 Answers
0
Just edit the hosts file, and put the name of the machine in there.
# vim /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 {hostname of your machine} localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
If you don't know the name of the host, then type: uname -a

Kevdog777
- 3,224
-
1That won't have any effect on other machines though. – Gilles 'SO- stop being evil' Mar 05 '15 at 22:48
-
Ok, thanks for that @Gilles. I have had to do these steps on my Virtual Machine (CentOS), and then was able to ping the machine from my own local machine (Windows), and see the name of the VM. – Kevdog777 Mar 06 '15 at 08:45