Welcome, Guest. Please login or register.
Did you miss your activation email?
February 09, 2006, 02:01:58 PM
Home Help Search Login Register
News: No News Is Good News

+  linuxfornewbies.org
|-+  HowTo's
| |-+  Networking
| | |-+  Setting the HOSTNAME
« previous next »
Pages: [1] Print
Author Topic: Setting the HOSTNAME  (Read 444 times)
Vern Heesch
Administrator
Newbie
*****
Posts: 22



View Profile
Setting the HOSTNAME
« on: June 30, 2005, 02:29:24 AM »

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:
Code:
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:
Code:
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:
Code:
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.
Logged
Pages: [1] Print 
« previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by PHP linuxfornewbies.org | Powered by SMF 1.0.5.
© 2001-2005, Lewis Media. All Rights Reserved.
Valid XHTML 1.0!Valid CSS!