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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
12-07-2007, 10:40 PM
|
#1
|
Member
Registered: Apr 2005
Location: Saratoga, NY
Distribution: Slackware
Posts: 322
Rep:
|
Test hostname
Is there a way I can test hostname to make sure it'll save over a reboot, without actually having to reboot?
|
|
|
12-08-2007, 04:24 AM
|
#2
|
Senior Member
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039
Rep:
|
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
|
|
|
12-08-2007, 12:59 PM
|
#3
|
Member
Registered: Apr 2005
Location: Saratoga, NY
Distribution: Slackware
Posts: 322
Original Poster
Rep:
|
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".
|
|
|
12-08-2007, 01:19 PM
|
#4
|
Senior Member
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039
Rep:
|
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
|
|
|
12-08-2007, 02:33 PM
|
#5
|
Member
Registered: Apr 2005
Location: Saratoga, NY
Distribution: Slackware
Posts: 322
Original Poster
Rep:
|
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.
|
|
|
12-08-2007, 02:39 PM
|
#6
|
LQ Guru
Registered: Jan 2001
Posts: 24,149
|
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
|
|
|
12-08-2007, 02:52 PM
|
#7
|
Member
Registered: Apr 2005
Location: Saratoga, NY
Distribution: Slackware
Posts: 322
Original Poster
Rep:
|
Quote:
Originally Posted by trickykid
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.
|
|
|
12-08-2007, 02:56 PM
|
#8
|
Senior Member
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039
Rep:
|
You could modify the script to use:
/bin/hostname $(cat /etc/HOSTNAME)
Instead of:
/bin/hostname $(cat /etc/HOSTNAME | cut -f1 -d .)
|
|
|
12-08-2007, 03:21 PM
|
#9
|
Member
Registered: Apr 2005
Location: Saratoga, NY
Distribution: Slackware
Posts: 322
Original Poster
Rep:
|
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.
|
|
|
12-08-2007, 06:28 PM
|
#10
|
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.x
Posts: 18,434
|
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 '.'
|
|
|
12-08-2007, 06:58 PM
|
#11
|
Member
Registered: Apr 2005
Location: Saratoga, NY
Distribution: Slackware
Posts: 322
Original Poster
Rep:
|
I understand that. What I don't understand is WHY it is being done.
|
|
|
12-09-2007, 01:03 AM
|
#12
|
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
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.
|
|
|
12-17-2007, 07:08 AM
|
#13
|
Senior Member
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
|
OP, does that make sense[/I]?
(It does to me, at least after just a little thought.)
Do you need more explanation?
|
|
|
All times are GMT -5. The time now is 07:08 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|