# [Solved] I can't seem to set the hostname

## Galumph

As part of a recent endeavor to fix my old and messy system, I thought I'd tackle a problem that's been bugging me ever since I installed Gentoo, but after a couple of hours of googling I couldn't find an answer. Ever since I installed Gentoo I couldn't get the hostname working right. I've tried setting it under etc and under conf.d but it doesn't seem to work. How do I set it?

```
root # cat /etc/hostname

Tux

root # cat /etc/conf.d/hostname

hostname="Tux"

root # /etc/init.d/hostname restart 

hostname           | * WARNING: you are stopping a boot service

syslog-ng          | * Stopping syslog-ng ...                                             [ ok ]

hostname           | * Setting hostname to Tux ...                                        [ ok ]

syslog-ng          | * Starting syslog-ng ...                                             [ ok ]

root # hostname -s

hostname: Unknown host
```

Last edited by Galumph on Sat Jul 14, 2012 10:51 pm; edited 1 time in total

----------

## The Doctor

I think you are confusing two different issues.

I think you want your computer to display a prompt like user@Tux ~$ right?

Then just restart. I don't think your /etc/hostname file does anything, as I don't have one, but if some application installed it, then its probably ok.

 *Quote:*   

> root # hostname -s 
> 
> hostname: Unknown host

 

This is a separate issue that has nothing to do with your hostname file to solve that do this: nano -w /etc/hosts

There should be a line something like this. edit it.

```
(This defines the current system)

127.0.0.1     tux.homenetwork tux localhost
```

for more detail, you can look at  chapter 8 of the handbook. Check the section labled Writing Down Network Information

----------

## Galumph

The computer does display a user@Tux prompt, I just set it to "user \$". It even sets the $HOSTNAME variable correctly, hostname just doesn't show the host for some reason.

I think I created /etc/hostname at some point after seeing it on old Slackware installation. Setting the hostname in the hosts file does the trick, hostname -s now shows the hostname:

```
root # hostname -s

Tux
```

Thanks

----------

