Previous Table of Contents Next


Module 65
hostname (BSD)

DESCRIPTION

The external hostname command sets or displays the name of the current host system. It is a network related command. System V based operating systems do not support hostname unless networking software has been installed. All BSD based operating systems support hostname as a standard command. It is a simple substitute for the uname command.

Only the super-user can change the hostname of the computer. By specifying a new hostname as an argument to hostname the super-user can change the system's hostname. The hostname is usually set at boot time in the /etc/rc.local on BSD systems. System V systems usually use the uname -n commands to set the hostname during system boot in the /etc/rc or /etc/rc2.d/SXX file.

COMMAND FORMAT

Following is the general format of the hostname command.

     hostname [ name_of_host ]

Arguments

Only one argument may be passed to the hostname command.

name_of_host The name of your local host system. The computer you are currently logged into.

RELATED COMMANDS

Refer to the uname command described in Module 148.

APPLICATIONS

You will find the hostname command useful if you use systems connected to one another via a LAN. The standard UNIX LAN is Ethernet using the TCP/IP protocol. When you log in from one system to the next you may find yourself forgetting which system you are currently logged into. By using hostname you can find out the system's name.

Many users set their shell prompt to the output of hostname. For example,

     PS1="`hostname`> "

TYPICAL OPERATION

In this activity you use the hostname command to display the name of the system you are currently using. Begin at the shell prompt.

1.  Type hostname and press Return. Notice the name of the system is returned.
2.  Turn to Module 144 to continue the learning sequence.


Previous Table of Contents Next