Quantcast
Channel: OS X computer name not matching what shows on terminal - Ask Different
Viewing all articles
Browse latest Browse all 11

Answer by mklement0 for OS X computer name not matching what shows on terminal

$
0
0

There are two potential reasons for the shell ($HOSTNAME variable, '\h' in $PS1) and the hostname utility to report a hostname that differs from the one shown in System Preferences > Sharing:

  • sudo scutil --set HostName newName was used to persistently change the hostname - unfortunately, this value is independent of the LocalHostName value set by System Preferences behind the scenes - even though man hostname suggests this method, DO NOT USE IT for that reason; run sudo scutil --set HostName '' to remove it, at which point LocalHostName should again be reported; for background, see this post by @Lauri Ranta.

  • [Update: The following is no longer true as of OSX 10.10] If your /etc/hosts file has an entry that matches your machine's IP address, that entry's name will be reported.

Only if neither of the above is true will the shell and hostname reflect the value set via System Preferences.


If you want to change your hostname from the shell, run both of the following:

  • sudo scutil --set LocalHostName <newName>
  • sudo scutil --set ComputerName <newFriendlyName>

where <newFriendlyName> can be a friendlier version (spaces, punctuation) of <newName> (alphanumerics and dashes only).


Viewing all articles
Browse latest Browse all 11

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>