If you are new to linux you probably will ask how to change the hostname of you computer. (A hostname is the unique name by which a network attached device is known on a network.) If you enter the wrong hostname during the installation, and you need to change the hostname, here is the solution:-
- Edit file /etc/sysconfig/network using your favourite editor. In my case is nano. So i’ll enter nano /etc/sysconfig/network
- Look for HOSTNAME=xxxxxx
- Change the xxxx to the name you wish to set for your computer. (ex: HOSTNAME=techiecorner.com)
- Save the file and restart the xinetd service. (ex: type service xinetd restart in your shell)
- Done! You have just changed your hostname in Linux platform
[tags]linux hostname, change linux hostname, change hostname, hostname, host, linux host[/tags]
SVN: How to commit only modified files via command line
How to setup syslog server in UBuntu 8
How to enable personal file sharing in Ubuntu 10.04
How to show line number in vi / vim editor
How to setup mysqldump without password in cronjob
How to install flash player in Ubuntu
Free image editor for Mac OS X / XP / Vista / Linux
How to create bootable Linux USB drive - UNetbootin
Share this with your friends:-
anybody tell me how to install localhost in (Apache) in fedora 14
Thanks Niraj karn!!
I tried it in SUSE linux but could not find /etc/init.d… I am using SUSE 9 enterprise edition.
Please let me know if I am missing something.
Hi In Suse :
1) u have to change host name in : vi /etc/HOSTNAME
2) after that vi /etc/hosts — change here also ….
3) Restart the Network services ” /etc/init.d/network restart
Then do #hostname ….
U will get expected result 🙂
to change hostname on rhel5
save and exit
# vi /etc/hosts
save and exit
#service network restart
#service xinetd restart
Actually both are right BUT , using hostname XXXXX is a way to change the hostname TEMPORARILY, so ona reboot th old one returns. To change permanently either use the newtork configurator (gui) or follow the steps to edit /etc/hosts & /etc/sysconfig/network as above
hiccup, burp …
Thank you unixman2. Very helpful!
Very helpful….if your in Canada ….beer on me 🙂
Thanks Mr. UnixMan!!! you’re the MAN!!! and I owe you a beer!!!
thanks unixman2 for ur advice 🙂
Sorry, no beer for you today because you left out 3 key steps in addition to yours.
#1 Edit the /etc/hosts file to replace the old hostname
#2 hostname xxxxxx xxxxxx=new hostname
#3 service network restart this resets your network interface
Now, you owe me a beer.
In my case it worked by editing the /etc/sysconfig/network.
directly using hostname xxxx doesn’t work.
Just type “hostname xxxxxx”
where xxxxx is your pc’s name
Sadly, this doesn’t work all the time. I’ve found that more often than not, the change doesn’t take effect despite restarting xinetd. Instead, the only way to make it happen has been to reboot the server. Not always, but most of the times that I’ve had to do this.