Vern Heesch
Administrator
Newbie
    
Posts: 22
|
I run Mandriva Linux so this howto is geared toward that. This may work on other distro's, I'm just not sure how consistent file naming is across distro's.
You can change your hostname permanently, or just temporarily. To view your current hostname you can run the following command as either a user or as root:
hostname
To change the hostname on a temporary basis, meaning it won't keep on a reboot, you can run this command as root. Keep in mind that it won't change the hostname seen in any open terminals/consoles. You would need to close and reopen them. Also, sometimes some applications do not respond well to this temporary method and require a reboot:
hostname newhostname
To change the system hostname on a permanent basis requires editing a few files as root. The first file we'll edit is the /etc/hosts file. Open the file as root in any editor you wish. You should see a line similar to:
127.0.0.1 localhost
Edit the line so its like this:
127.0.0.1 newhostname localhost
Save the file.
Now we edit the /etc/sysconfig/network file. Add the following line to this file:
HOSTNAME=newhostname
Save the file.
Now you should reboot for these changes to take effect. But first........
Note that in some cases the ISP itself is assigning the hostname. If the above procedure does not work, then most likely this is what's happening. In such a case, you would edit a third file. Which file depends on what interface your connection is using. To find out, type the following as root:
ifconfig
You should see a couple of interfaces, one being lo. The other is the one we want and could be something like eth0, or eth1, or wlan0, or something similar. In our case we'll say it showed the eth0 interface. This means the the file we would need to edit would be the /etc/sysconfig/network-scripts/ifcfg-eth0 file. Add the following line to the file:
NEEDHOSTNAME=no
This change would also require a reboot for it to take effect.
If everything went well, you now have the system HOSTNAME that you preferred.
|