LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-26-2012, 06:51 AM   #1
pratapsingh
LQ Newbie
 
Registered: Oct 2009
Posts: 22

Rep: Reputation: 0
Exclamation Hostname command prints nothing a null value


Hi ,

On my box everything works fine. But whenever I run command

Quote:
[root@(none) ~]#/bin/hostname
[root@(none) ~]#
It returns nothing as you see @(none) too.


Quote:
[root@(none) ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain
::1 localhost localhost.localdomain
192.168.144.128 localhost localhost.localdomain

[root@(none) ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME="localhost.localdomain"
[root@(none) ~]#

[root@(none) ~]# printenv | less
HOSTNAME=
SELINUX_ROLE_REQUESTED=
TERM=xterm
SHELL=/bin/bash
HISTSIZE=1000


[root@(none) ~]# which hostname
/bin/hostname
[root@(none) ~]#


[root@(none) ~]# cat /etc/HOSTNAME
127.0.0.1 localhost localhost.localdomain

[root@(none) ~]# /bin/hostname localhost.localdomain
[root@(none) ~]# hostname

[root@(none) ~]#
Its very strange issue I have never noticed on any other system yet.

Any one have any idea about this.

Thank you

Last edited by pratapsingh; 02-26-2012 at 06:54 AM.
 
Old 02-26-2012, 07:25 AM   #2
haveanother
LQ Newbie
 
Registered: Jan 2011
Posts: 13

Rep: Reputation: 0
Code:
/etc/hostname
Is different from
Code:
/etc/HOSTNAME
since Linux is case-sensitive.

You need the first one of those.

This might contain some useful help too:

Code:
man resolv.conf
Hope this helps
 
Old 02-26-2012, 07:40 AM   #3
pratapsingh
LQ Newbie
 
Registered: Oct 2009
Posts: 22

Original Poster
Rep: Reputation: 0
I created file /etc/hostname

Quote:
[root@(none) ~]# cp -p /etc/HOSTNAME /etc/hostname
[root@(none) ~]# ll /etc/hostname
-rw-r--r--. 1 root root 45 Feb 20 04:16 /etc/hostname
[root@(none) ~]# cat /etc/hostname
127.0.0.1 localhost localhost.localdomain
Deleted this one /etc/HOSTNAME and rebooted the system too It did not help either

Thanks for your reply
 
Old 02-26-2012, 11:08 AM   #4
haveanother
LQ Newbie
 
Registered: Jan 2011
Posts: 13

Rep: Reputation: 0
Hey maybe I figured out what you are trying to do.

Here is an article that describes how to change the hostname of a linux system: http://www.ducea.com/2006/08/07/how-...-linux-system/

Code:
127.0.0.1 localhost localhost.localdomain
This is probably not a valid format for /etc/hostname

That format works only for /etc/hosts

These 2 files are completely different ! !



I tried to set my /etc/hostname to the same value as in your example (" 127.0.0.1 localhost localhost.localdomain ").

Code:
# cat /etc/hostname
127.0.0.1 localhost localhost.localdomain
Then I used the example command (from that article that I linked to), to reload the hostname value:

Code:
/etc/init.d/hostname.sh start
And got this response:

Code:
hostname: the specified hostname is invalid
So maybe that is the same problem as you have.

I then changed the /etc/hostname value to this: localhost

Code:
# cat /etc/hostname
localhost
Then tried this command again to reload it:

Code:
/etc/init.d/hostname.sh start
And it was successful. Perhaps this will also work for you.
 
Old 02-27-2012, 10:34 AM   #5
pratapsingh
LQ Newbie
 
Registered: Oct 2009
Posts: 22

Original Poster
Rep: Reputation: 0
Thanks all for your reply I found the solution and it was nothing with my setting it was due to the rpm package "net-tool". I just upgraded it using yum and it was fixed .

Also I found that file "/bin/hostname" was an empty file.

Thank you
 
Old 02-27-2012, 10:43 AM   #6
EDDY1
LQ Addict
 
Registered: Mar 2010
Location: Oakland,Ca
Distribution: wins7, Debian wheezy
Posts: 6,841

Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
http://www.randombugs.com/linux/chan...ux-system.html
 
Old 02-27-2012, 12:17 PM   #7
EDDY1
LQ Addict
 
Registered: Mar 2010
Location: Oakland,Ca
Distribution: wins7, Debian wheezy
Posts: 6,841

Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
Can you post the solution to your problem so that others experiencing same problem can benefit from it.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
problem with 'less' command - prints garbage when piped. spoovy Slackware 11 03-09-2010 04:07 AM
CUPS Printer Problem - prints, but prints gibberish Sparrowhawk Debian 2 06-19-2006 07:32 PM
cups prints poorly, while lpr from command line prints well spindles Linux - Software 2 04-01-2006 04:02 AM
prints should go in queue by issuing print command. bhagi123 Linux - Software 0 02-24-2006 05:18 AM
hostname command vs. $HOSTNAME env. variable Silly22 Linux - Networking 2 03-29-2002 05:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:47 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