Networking Forums

Networking Forums > Computer Networking > Linux Networking > hostname command not working

Reply
Thread Tools Display Modes

hostname command not working

 
 
hans
Guest
Posts: n/a

 
      09-19-2003, 11:26 PM
Hi,

I've installed RH 9. When it boots and i log in as root (or whatever
user) the prompt always is: [root@(none).

When i run hostname, it does not return anything. When i run hostname
with a name behind it, e.g. hostname mycomputer, and i run hostname
again, the hostname is not set.

In my /etc/hosts i have:
127.0.0.1 localhost.localdomain localhost
10.0.0.155 mycomputer.localnet mycomputer

In my /etc/sysconfig/network i have:
NETWORKING=yes
HOSTNAME=mycomputer.localnet
DOMAINNAME=localnet
FORWARD_IPV4=yes
GATEWAY=10.0.0.138

What can be wrong and why is the hostname command not working?

Cheers,
Hans
 
Reply With Quote
 
 
 
 
Paul Lutus
Guest
Posts: n/a

 
      09-20-2003, 05:16 PM
hans wrote:

> Hi,
>
> I've installed RH 9. When it boots and i log in as root (or whatever
> user) the prompt always is: [root@(none).


What hostname did you assign during the installation?

What is in /etc/sysconfig/network?

What is in /etc/sysconfig/networking/profiles/default/network?

Do you know that a hostname doesn't have a domain attached to it? If you
were mysite.com, the hostname is "mysite," the domain name is "com."

> When i run hostname, it does not return anything. When i run hostname
> with a name behind it, e.g. hostname mycomputer, and i run hostname
> again, the hostname is not set.


No way (as root). Try this again:

# hostname myhost

# hostname
myhost

Always, perpetually, forever (as root).

>
> In my /etc/hosts i have:
> 127.0.0.1 localhost.localdomain localhost
> 10.0.0.155 mycomputer.localnet mycomputer


>
> In my /etc/sysconfig/network i have:
> NETWORKING=yes
> HOSTNAME=mycomputer.localnet


That is not a hostname. A hostname would be "mycomputer".

> DOMAINNAME=localnet
> FORWARD_IPV4=yes
> GATEWAY=10.0.0.138
>
> What can be wrong and why is the hostname command not working?


Perhaps you need to read up a tiny bit on hostnames.

--
Paul Lutus
http://www.arachnoid.com

 
Reply With Quote
 
Tim Hammerquist
Guest
Posts: n/a

 
      09-21-2003, 07:41 PM
hans graced us by uttering:
> I've installed RH 9. When it boots and i log in as root (or
> whatever user) the prompt always is: [root@(none).


IIRC, some linux distros keep their hostname (to be set at
startup) in a text file in /etc. Try looking at the files/dir
returned by:

ls /etc/* | grep -i hostname

I think it was called /etc/HOSTNAME on the Mandrake Linux box I
ran several years ago. May be the same for you with Redhat.

HTH,
Tim Hammerquist
--
I must've seen it in a USENET posting; that's sort of like
hearsay evidence from Richard Nixon...
-- Blair Houghton
 
Reply With Quote
 
Bit Twister
Guest
Posts: n/a

 
      09-21-2003, 09:11 PM
On 21 Sep 2003 12:41:39 -0700, Tim Hammerquist wrote:
> hans graced us by uttering:
>> I've installed RH 9. When it boots and i log in as root (or
>> whatever user) the prompt always is: [root@(none).

>
> IIRC, some linux distros keep their hostname (to be set at
> startup) in a text file in /etc. Try looking at the files/dir
> returned by:
>
> ls /etc/* | grep -i hostname
>
> I think it was called /etc/HOSTNAME on the Mandrake Linux box I
> ran several years ago.


Must have been before MD release 8.x
Redhat and Mandrake have it in /etc/sysconfig/network

HOSTNAME=wb.home <=====
NETWORKING=yes
GATEWAY=192.168.1.1
GATEWAYDEV=eth0
 
Reply With Quote
 
Tim Hammerquist
Guest
Posts: n/a

 
      09-21-2003, 10:01 PM
Bit Twister graced us by uttering:
> Tim Hammerquist wrote:

<snip>
>> I think it was called /etc/HOSTNAME on the Mandrake Linux box I
>> ran several years ago.

>
> Must have been before MD release 8.x
> Redhat and Mandrake have it in /etc/sysconfig/network


Yeah, it was. I jumped Mandrake's ship long before 8.x. :-/

I believe that Slackware also uses /etc/HOSTNAME, and my Debian
box uses /etc/hostname.

FYI,
Tim Hammerquist
--
The optimist thinks this is the best of all possible worlds.
The pessimist fears it is true.
-- Robert Oppenheimer
 
Reply With Quote
 
Anssi Porttikivi
Guest
Posts: n/a

 
      09-22-2003, 08:18 AM
I would like to ask for clarification here: can I trust, that the kernel
remembers te hostname set with the hostname' command, and all other
programs use the `hostname` as returned by a system call. So that the
contents of /etc/sysconfig/network or /etc/hostname really don't matter,
if the rc scripts decide to read the hostaname from somewhere else? No
applications will read the /etc files for hostname?
 
Reply With Quote
 
Bit Twister
Guest
Posts: n/a

 
      09-22-2003, 12:40 PM
On Mon, 22 Sep 2003 11:18:25 +0300, Anssi Porttikivi wrote:
> I would like to ask for clarification here: can I trust, that the kernel
> remembers te hostname set with the hostname' command, and all other
> programs use the `hostname` as returned by a system call.


Yes, you can trust hostname to remember hostname and scripts to use hostname.

> So that the
> contents of /etc/sysconfig/network or /etc/hostname really don't matter,
> if the rc scripts decide to read the hostaname from somewhere else?


It matters when the system is booted. That is where hostname is called
to set the node's hostname or in the case of Redhat and Mandrake,
starting the network will call hostname using the value from
/etc/sysconfig/network.


> No applications will read the /etc files for hostname?


As a rule, yes, except for the system configuration applicaions.
 
Reply With Quote
 
Paul Lutus
Guest
Posts: n/a

 
      09-22-2003, 07:55 PM
Anssi Porttikivi wrote:

> I would like to ask for clarification here: can I trust, that the kernel
> remembers te hostname set with the hostname' command, and all other
> programs use the `hostname` as returned by a system call.


NO, and no (not consistently).

> So that the
> contents of /etc/sysconfig/network or /etc/hostname really don't matter,


No, the reverse. The contents of these files is crucial, because the system
doesn't remember what you type into the "hostname" command after reboot.

> if the rc scripts decide to read the hostaname from somewhere else? No
> applications will read the /etc files for hostname?


Edit /etc/sysconfig/network

and /etc/sysconfig/networking/profiles/default/network

and reboot. See what happens.

--
Paul Lutus
http://www.arachnoid.com

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SP3 Netsh command does not include wlan command. Stephen Liffen Wireless Networks 4 09-15-2008 02:42 PM
/bin/hostname Vwaju Linux Networking 4 08-25-2008 07:56 PM
"brctl" command not working, how to create "brctl" file? santa19992000@yahoo.com Linux Networking 1 06-05-2005 12:38 AM
net send command not working: Mario Windows Networking 3 03-04-2004 11:00 PM
ipsec and hostname command Pawel Banys Linux Networking 1 01-13-2004 06:33 PM



1 2 3 4 5 6 7 8 9 10 11