LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 11-28-2009, 06:55 AM   #1
tulsi
Member
 
Registered: Aug 2009
Location: Chennai
Posts: 54

Rep: Reputation: 15
Question setting /bin/hostname [failed]


In my system(Centos) has setting /bin/hostname [failed] while at the booting time.
machine name has "localhost " both the /bin/hostname and /etc/hostname have localhost.
I enter the command line but like
>/bin/hostname
/bin/hostname: line 1: localhost: command not found

please help me.
 
Old 11-28-2009, 07:03 AM   #2
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
What is the output from
Code:
cat /etc/hostname
 
Old 11-28-2009, 08:15 AM   #3
tommylovell
Member
 
Registered: Nov 2005
Distribution: Raspbian, Debian, Ubuntu
Posts: 380

Rep: Reputation: 103Reputation: 103
I was under the impression that CentOS was like RHEL. If that is the case, /etc/sysconfig/network should contain a HOSTNAME= entry that is used by /etc/rc.d/sysinit to set the hostname at boot time.

Code:
[root@athlonz ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=athlonz.tomlovell.com

[root@athlonz rc.d]# hostname
athlonz.tomlovell.com
[root@athlonz rc.d]#

/bin/hostname is an executable
Code:
[root@athlonz ~]# file /bin/hostname
/bin/hostname: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped
Also, I have an entry in /etc/hosts so that reverse lookups will work, but I don't think that is necessary or even related to setting the hostname.

Code:
[root@athlonz rc.d]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       localhost.localdomain localhost
192.168.1.94    athlonz.tomlovell.com athlonz
[root@athlonz rc.d]#
If this is not the case on CentOS, my apologies for adding to the confusion.

Last edited by tommylovell; 11-28-2009 at 08:21 AM. Reason: addl info
 
Old 11-29-2009, 05:29 AM   #4
tulsi
Member
 
Registered: Aug 2009
Location: Chennai
Posts: 54

Original Poster
Rep: Reputation: 15
>file /bin/hostname
output is

ASCII output

cat /bin/hostname
/bin/hostname line 1: localhost command not found

I have no backup for /bin/hostname.
and I set the the hostname in /etc/sysconfig/network and /etc/hostname is localhost. but nothing change. while system startup got like

/bin/hostname line 1: localhost command not found

please help me.

Last edited by tulsi; 11-30-2009 at 03:55 AM.
 
Old 11-29-2009, 05:36 AM   #5
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
Quote:
Originally Posted by tulsi View Post
>file /bin/hostname
output is

ASCII output

cat /bin/hostname
/bin/hostname line 1: localhost command not found
Seems to me you have altered the file.
You need to set the hostname in
Code:
/etc/hostname
Do you have a backup from
Quote:
/bin/hostname
 
Old 11-29-2009, 06:18 AM   #6
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Rep: Reputation: 116Reputation: 116
Quote:
Originally Posted by repo View Post
Seems to me you have altered the file.
You need to set the hostname in
Code:
/etc/hostname
Do you have a backup from
nah...there isnt a file called /etc/hostname.
there used to be /etc/HOSTNAME on older versions, but like tommylovell says...
hostname is set on the command line & in /etc/sysconfig/network
 
Old 11-29-2009, 06:36 AM   #7
eth1
Member
 
Registered: May 2008
Posts: 97

Rep: Reputation: 20
Try setting the hostname in /etc/sysconfig/network, restarting/quitting the shell and then checking the hostname.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Failed to chck remot comnd executin using shells /usr/bin/ssh and /usr/bin/rsh farnaw4u Linux - Software 2 04-06-2009 12:08 AM
Setting Hostname abhijeetudas Linux - Networking 1 06-04-2005 07:10 AM
broke /bin/hostname nitsky416 Linux - Networking 2 11-30-2003 04:45 AM
setting hostname akamol Linux - General 2 07-03-2003 03:48 AM
setting up a hostname sakeeb Linux - Networking 3 04-28-2002 04:37 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 02:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration