hostname

Print or Set (temporarily) the name of current host system.

Syntax
   hostname [-fs] [name-of-host]

Key
   -f    Include domain information in the printed name.
         This is the default behavior.

   -s    Trim off any domain information from the printed name.

The super-user can set the hostname by supplying a hastname argument.
To keep the hostname between reboots, run `scutil --set HostName name-of-host'.

If a NetBIOSName has been configured, (it is typically set to = the hostname) the value is stored in a preference file:
$ defaults read /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName

You can set the NetBIOSName in System Preferences > Network > active network port > Advanced > WINS tab.

Examples

Display the current hostname

$ hostname

The hostname is also stored in a system variable named HOSTNAME

$ echo $HOSTNAME

“ One thing you don't want to do as a host is be running around all evening. Do as much as you can ahead of time, so all you have to do is grill the main ingredients” ~ Bobby Flay

Related:

hostname man page - Apple.com
scutil - Manage system configuration parameters, including hostname
dscacheutil -flushcache


© Copyright SS64.com 1999-2016
Some rights reserved