LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   hostname vs. HOSTNAME ? (https://www.linuxquestions.org/questions/linux-newbie-8/hostname-vs-hostname-529597/)

sirius56 02-16-2007 07:50 AM

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.

james.farrow 02-16-2007 08:13 AM

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!

pixellany 02-16-2007 08:16 AM

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....


All times are GMT -5. The time now is 03:35 PM.