Ubuntu setting hostname correctly?

Posted on 2011-10-18
Last Modified: 2012-05-12
I used the hostname command to set my host name. I think its working because when I type the command "hostname" with no arugments it returns the hostname that I set.

However when I type this "echo $hostname" I get a blank line returned. Why is that happening?
Question by:steiner470
    LVL 7

    Expert Comment

    This is correct behavior. it is due to the fact that hostname is a program that will return your hostname and $hostname is a variable that you have not loaded (there is nothing associated to it). so an unloaded variable has no response or blank.

    Author Comment

    OK so how do I "load" the hostname variable?
    LVL 7

    Accepted Solution

    you don't need to, the hostname variable is for programming/scripts... you hostname IS set and set correctly. the proper test (in Ubuntu) is to use the command "hostname" not $hostname.

    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Suggested Solutions

    Network Interface Card (NIC) bonding, also known as link aggregation, NIC teaming and trunking, is an important concept to understand and implement in any environment where high availability is of concern. Using this feature, a server administrator …
    I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
    Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
    Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now