Linux, change Host Name

View previous topic View next topic Go down

Linux, change Host Name

Post by CureMyMind on Wed Jan 26, 2011 9:40 pm

This is to change the host name of your linux box. This should work with all Linux distrios. I will be using gedit, you can use your favorit text editor. I also like using nano but I will be using gedit and also BackTrack Linux. I have tried this in Ubuntu linux and it should work the exact same way. Now before we get started you will use sudo infront of the command if you are not in root. This will give it root privileges. To konw that command infront of the command it stands for super user and do, as in do these commands in super user mode aka root. Now to begin...

  • 1. Open your (shell/terminal/konsole/terminator) which ever it's called in your Linux box. It should be on the panel of BackTrack. I will be calling it terminal even tho in BackTrack it's called konsole. It's just my preference of word.

  • 2. In the black box or the black transparent box type in gedit /etc/hostname and press enter on your keyboard.


EX
Code:
root@bt:~# gedit /etc/hostname

  • 3. Enter your password in the text box if applictable. In that section you will not see anything you type in but it is in there so do not panic. Just make sure its correct.


  • 4. Once gedit opens up, erase everything in there. That was the old hostname. We want to put a new one. In BackTrack it will be bt, and in Ubuntu it will be ubuntu. Note that in the terminal that it says root@bt where bt is the hostname. That will be changed to what ever you put in gedit. In Ubuntu its name@ubuntu where ubuntu is the hostname. Now that you get the picture of what I mean, you will be able to change it with gedit text editor. I used name heart.


  • 5. Now once you have changed the hostname you want to save it. In gedit its just the save button or ctrl+s and thats the letter s. Once you have saved it close it.


Before we reboot we have to fix more things soo keep your terminal open.

  • 6. You will need to edit the hosts file so in your terminal type in gedit /etc/hots.


Ex.
Code:
root@bt:~# gedit /etc/hosts

It should like like this.
Code:
127.0.0.1      localhost
127.0.1.1      backtrack bt

# The following lins are desirable for IPV6 capable hosts
::1            localhost ipv6-localhost ipv6-loopback
fe00::0        ipv6-localnet
ff00::0        ipv6-mcastprefix
ff02::1        ipv6-allnodes
ff02::2        ipv6-allrouters
ff02::3        ipv6-allhosts

Put a # sign infront of...

127.0.0.1 localhost
So it looks like
#127.0.0.1 localhost

then add this with no quotes and also change where it says hostname to what ever you want

127.0.0.1 localhost "hostname".domain.local "hostname"

where ever it says "hostname" replace with what you did in steps 1 though 5. I used heart. so mine should look like

127.0.0.1 localhost heart.domain.local heart

EX. So change heart to what ever you used in steps 1 though 5.
Code:
#127.0.0.1      localhost
127.0.0.1      localhost heart.domain.local heart
127.0.1.1      backtrack bt

# The following lins are desirable for IPV6 capable hosts
::1            localhost ipv6-localhost ipv6-loopback
fe00::0        ipv6-localnet
ff00::0        ipv6-mcastprefix
ff02::1        ipv6-allnodes
ff02::2        ipv6-allrouters
ff02::3        ipv6-allhosts

Save your work as before.

NOW: Cross your fingers... remember I used heart... Now do these next commands

1. Command hostname and you should get hostname at the bottom with no errors.
EX.
Code:
root@bt:~# hostname
hostname
root@bt:~#

2. Command hostname -a and you should get hostname.domain.local hostname with no errors. I used heart so mine will look like this heart.domain.local heat.
EX. Where it says heart it will say what ever you used in steps 1 though 5.
Code:
root@bt:~# hostname -a
heart.domain.local heart
root@bt:~#

3. Command hostname -f and you shoudl get localhost with no errors.
EX.
Code:
root@bt:~# hostname -f
localhost
root@bt:~#

  • 7. Now restart your Linux box. Upon restart you should get zero errors. If you do please go back and look at where you went wrong. Also if I made a mistake please tell me.


ENJOY!

_______________________________________________
I don't do things because they are hard nore because they are needed. I do them simply because I can -CureMyMind

CureMyMind
Admin

Posts : 69
Join date : 2011-01-15

View user profile http://curemymind.4umer.net

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum