matt2kjones
07-02-2002, 05:57 PM
hi how do you set the hostname in linux?
im a complete newbie, and its taking a while to adapt
im a complete newbie, and its taking a while to adapt
![]() | View Full Version : how do you set the hostname in linux? matt2kjones 07-02-2002, 05:57 PM hi how do you set the hostname in linux? im a complete newbie, and its taking a while to adapt phpjames 07-02-2002, 06:19 PM Edit the /etc/hosts file from the command line. # pico /etc/hosts Add the line but do not remove the first line. Control O Control X taz0 07-02-2002, 08:07 PM man hostname /etc/hostname phpjames 07-02-2002, 08:23 PM Woops correct me if I am wrong. ToastyX 07-02-2002, 09:05 PM Each Linux distribution has a different way of setting the host name, and if you're using control panel software, that can complicate things. I'm not sure about other control panels, but if you're using Cpanel, you should change the host name using WHM. Otherwise, In Red Hat Linux, edit /etc/sysconfig/network and change HOSTNAME to whatever you want the host name to be. For example, if you want the host name to be my.host.name, the line should look like this: HOSTNAME=my.host.name It is also a good idea to add the host name to /etc/hosts. Edit /etc/hosts and add a line with your server's main IP address followed by the host name. For example, if your server's main IP address is 127.142.128.35, the line should look like this: 127.142.128.35 my.host.name Then on the shell, type hostname followed by the host name and press Enter. For example: hostname my.host.name That should take care of it. If you're a control panel, restart the control panel software, or reboot. roly 07-02-2002, 09:30 PM Just enter this: hostname google.com reboot Mdot 07-02-2002, 09:39 PM hehe, why do you need to reboot? :D ToastyX 07-02-2002, 09:56 PM Originally posted by roly Just enter this: hostname google.com reboot ...but that doesn't save the host name, so when you reboot, wouldn't it revert back to the old host name? MotleyFool 07-03-2002, 02:44 AM You should also remember to add an A record for the hostname in your domain's DNS . If for example you are going to use peacock.xanadu.com as the host name for a server you should have 1] an A record for pecock.xanadu.com in the DNS info of xanadu.com [it is not necessary that either the DNS or xanadu.com be hosted on the server] 2] the A record should resolve to an IP on the server If hostname doesn't resolve Apache wouldn't start Cheers Balaji |