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:-
Advertisements
- 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]
Related posts:
How to check if directory exists in Bash script
How to use apt to list available packages?
How to split compressed file into smaller files in Linux / Mac
How to remove apache test page in CentOS
How to block .log file using in .htaccess
How to create symbolic link in Unix
Free image editor for Mac OS X / XP / Vista / Linux
How to block access to certain file types using .htaccess
Share this with your friends:-
anybody tell me how to install localhost in (Apache) in fedora 14
Thanks Niraj karn!!
Hi Raj,
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.
Thanks
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
#vi /etc/sysconfig/network
hostname:
save and exit
# vi /etc/hosts
edit
save and exit
#service network restart
#service xinetd restart
done
NirajKarn
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!
TYTYTYTY
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.