LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 12-07-2007, 10:40 PM   #1
Zeno McDohl
Member
 
Registered: Apr 2005
Location: Saratoga, NY
Distribution: Slackware
Posts: 322

Rep: Reputation: 30
Test hostname


Is there a way I can test hostname to make sure it'll save over a reboot, without actually having to reboot?
 
Old 12-08-2007, 04:24 AM   #2
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
In ubuntu (and other debian based distros) the hostname is reset at boot time with the data in the /etc/hostname file.

From a quick google search it appears that in Slackware this filename might be in uppercase:
/etc/HOSTNAME


Therefore if you want to know what your hostname would be after a reboot:
Code:
cd /etc
ls -1|grep -i hostname|xargs cat
 
Old 12-08-2007, 12:59 PM   #3
Zeno McDohl
Member
 
Registered: Apr 2005
Location: Saratoga, NY
Distribution: Slackware
Posts: 322

Original Poster
Rep: Reputation: 30
That's the problem. I've had my hostname set in that file for months. But when the server reboots, the hostname isn't set to that and is instead set to "zeno".
 
Old 12-08-2007, 01:19 PM   #4
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
I don't have Slackware available, however on ubuntu the hostname is set at boot by:

/etc/rcS.d/S02hostname.sh

which is linked to:

/etc/init.d/hostname.sh
 
Old 12-08-2007, 02:33 PM   #5
Zeno McDohl
Member
 
Registered: Apr 2005
Location: Saratoga, NY
Distribution: Slackware
Posts: 322

Original Poster
Rep: Reputation: 30
Here's what is done on boot:
Code:
# Set the hostname.
if [ -r /etc/HOSTNAME ]; then
  /bin/hostname $(cat /etc/HOSTNAME | cut -f1 -d .)
else
  # fall back on this old default:
  echo "darkstar.example.net" > /etc/HOSTNAME
  /bin/hostname darkstar
fi
Why is it doing that? The cut line is cutting off the text at the .

Thus since I had zeno.biyg.org it simply turns into zeno. I can't have that happen, but I don't understand why it's doing that.

(The reason I can't have it set to zeno is because my email sends out from nobody@domain where domain seems to be set as the hostname, thus if it's nobody@zeno instead of the correct nobody@zeno.biyg.org, all email servers will reject the email)

Last edited by Zeno McDohl; 12-08-2007 at 02:34 PM.
 
Old 12-08-2007, 02:39 PM   #6
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 271Reputation: 271Reputation: 271
Just edit your HOSTNAME file with the name you want to use and be done with it. Every system has some type of script to determine the hostname at bootup. Red Hat will have the name set in /etc/sysconfig/network
 
Old 12-08-2007, 02:52 PM   #7
Zeno McDohl
Member
 
Registered: Apr 2005
Location: Saratoga, NY
Distribution: Slackware
Posts: 322

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by trickykid View Post
Just edit your HOSTNAME file with the name you want to use and be done with it. Every system has some type of script to determine the hostname at bootup. Red Hat will have the name set in /etc/sysconfig/network
Please read the thread. That doesn't work. I did set the HOSTNAME file as I already mentioned. But as you can see from the code I posted, the system does not fully read the file on boot. It only reads up to the first period and then stops.
 
Old 12-08-2007, 02:56 PM   #8
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
You could modify the script to use:

/bin/hostname $(cat /etc/HOSTNAME)

Instead of:

/bin/hostname $(cat /etc/HOSTNAME | cut -f1 -d .)
 
Old 12-08-2007, 03:21 PM   #9
Zeno McDohl
Member
 
Registered: Apr 2005
Location: Saratoga, NY
Distribution: Slackware
Posts: 322

Original Poster
Rep: Reputation: 30
Yeah I know I could do that. But I don't like changing system defaults without knowing why they were that way to begin with... There must be a reason.
 
Old 12-08-2007, 06:28 PM   #10
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.x
Posts: 18,434

Rep: Reputation: 2790Reputation: 2790Reputation: 2790Reputation: 2790Reputation: 2790Reputation: 2790Reputation: 2790Reputation: 2790Reputation: 2790Reputation: 2790Reputation: 2790
Consider
Code:
echo fred|cut -f1 -d .
fred

echo 'fred.g'|cut -f1 -d .
fred
IOW, if you have a hostame with a domain, it gets only the hostname, that's why the '.'
 
Old 12-08-2007, 06:58 PM   #11
Zeno McDohl
Member
 
Registered: Apr 2005
Location: Saratoga, NY
Distribution: Slackware
Posts: 322

Original Poster
Rep: Reputation: 30
I understand that. What I don't understand is WHY it is being done.
 
Old 12-09-2007, 01:03 AM   #12
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 683Reputation: 683Reputation: 683Reputation: 683Reputation: 683Reputation: 683
What it is doing is correct. If you enter "hostname" or "echo $HOST" you should see "zeno". If you enter "dnsdomainname" you should see "biyg.com".

You should concentrate on the email part of the problem. For example, if the email is sent from a cronjob, edit the cronjob so that the email is sent to a real user.

You could have a "nobody: root" entry in /etc/aliases so that the email gets sent to root.
 
Old 12-17-2007, 07:08 AM   #13
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
OP, does that make sense[/I]?
(It does to me, at least after just a little thought.)
Do you need more explanation?
 
  


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
LXer: One programmer's unit test is another's integration test LXer Syndicated Linux News 0 07-29-2007 03:46 AM
linux test bed vs. windows test bed Hewson Linux - General 1 06-20-2007 10:01 PM
LXer: Mozilla invites users to pre-test a test LXer Syndicated Linux News 0 08-09-2006 11:12 PM
FC4 Test 1 CD Test failes every DISC Jimbo99 Linux - Software 1 03-18-2005 03:16 PM
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 07:08 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