# Changing a hostname?

## christopher_farley

I want to change the hostname of a machine.  It seems like I should simply alter the hostname in /etc/hostname and do an env-update. However, all of the profile.env and csh.env all retain the old hostname.

Where is the hostname located, and how should I change it?

----------

## Ssl

Go for it  :Wink: 

Change /etc/hostname in an editor or

echo newname > /etc/hostname

Tried source /etc/profile ?

Ssl

----------

## christopher_farley

That's the thing.

I changed /etc/hostname

I ran env-update

The profile.env file still retains the *old* hostname.

Where else is the hostname?

----------

## christopher_farley

Resolved. 

I had to change the hostname in /etc/env.d/01hostname

Is that now the normal place to change the hostname? Hmm...

----------

## tbfr

in general you just have to edit /etc/hostname and run hostname --file /etc/hostname to activate the new hostname.

/etc/init.d/hostname restart writes the new hostname into /etc/env.d/01hostname too, seems to be the gentoo way.

rebooting the computer will work too of course. also take a look at /etc/hosts.

----------

