hostname on Solaris

Hi All,

I am wondering how does the hostname command decides what is the actual hostname. Where does the command take the information from?

From /etc/ hostname.<interface> name is the file which hostname command read to decide the hostname of the system.

I don't have access to a Solaris system right now to check for sure, but the contents of /etc/nodename are probably important, too.

Actually not, especially as you can have plenty of physical interfaces but have only one hostname at a given time.

Hostname initial setting is done by reading the /etc/nodename file.
DHCP, bootp or root might change the hostname later.

On Solaris the `hostname` command is a shell script that runs `uname -n` (and uses `uname -S ${1}` to set the hostname). I ran a `truss uname -n` to see if I could spot the location in memory or disk easily but I was not able to figure that out.

During boot the sysid tools check /etc/nodename and set the hostname of the system to the contents of that file.

The uname command uses the uname system call. The host name is stored in a kernel structure named "utsname".

True. But the change still has to be saved somewhere

the change done by "hostname" command are not stored anywhere (except the kernel). if you reboot your system, the setting is lost. if you want a permanent solution, you've to edit /etc/hostname.inteface and /etc/nodename!