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-16-2007, 07:50 AM   #1
sirius56
Member
 
Registered: Nov 2006
Location: Illinois
Distribution: Ubuntu 10.4
Posts: 35

Rep: Reputation: 15
hostname vs. HOSTNAME ?


What is the difference between issuing a hostname command, e.g.,

hostname mybox,

and changing the environment variable HOSTNAME=mybox ?


Thank you.
 
Old 02-16-2007, 08:13 AM   #2
james.farrow
Member
 
Registered: Mar 2003
Location: UK Darlington
Distribution: Fedora Freebsd Centos
Posts: 296

Rep: Reputation: 31
As far as I know the hostname command changes/reports the hostname but it will not survive a reboot - it will revert back to localhost.localdomain
The HOSTNAME variable SETS the hostname as the box boots.

Think thats right. On redhat/fedroa the file is /etc/sysconfig/network

Try it!
 
Old 02-16-2007, 08:16 AM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
After experimenting, here is my GUESS:

"hostname" changes the hostname immediately, whereas "export HOSTNAME=newname" changes the env variable and would become effective on the next reboot (or login??)
If either method is used it does not affect the other.

I have not tested to see what happens on reboot....
 
  


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
Two Ip with same hostname Frunktz Linux - Networking 4 03-05-2006 08:30 AM
hostname changes R153-Ab0V3 Linux - Newbie 6 01-10-2004 11:36 PM
hostname guyd Linux - Newbie 5 08-18-2003 09:07 PM
hostname lansman Linux - Newbie 6 03-01-2003 07:47 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 11:01 PM.

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