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 02-16-2007, 08: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, 09:13 AM   #2
james.farrow
Member
 
Registered: Mar 2003
Location: UK Darlington
Distribution: Fedora Freebsd Centos
Posts: 288

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, 09:16 AM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
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 09:30 AM
hostname changes R153-Ab0V3 Linux - Newbie 6 01-11-2004 12:36 AM
hostname guyd Linux - Newbie 5 08-18-2003 10:07 PM
hostname lansman Linux - Newbie 6 03-01-2003 08:47 AM
hostname command vs. $HOSTNAME env. variable Silly22 Linux - Networking 2 03-29-2002 06:01 PM


All times are GMT -5. The time now is 04:44 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration