Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Manually change the computer name System
I have been trying to find were OS X is setting the name of the computer that is shown in the login panel. I checked all of the hostconfig type files and found nothing for changing this setting. I finally discovered that Apple is using their own file to store this information, found here:


This is the section of the file that holds the computer name:

  • Currently 3.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)

Manually change the computer name | 8 comments | Create New Account
Click here to return to the 'Manually change the computer name' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Authored by: sjonke on Mar 11, '02 09:36:55PM

If I'm not mistaken, as with OS 9 and prior, the name of the computer is in the Sharing preferences (in the system preferences, Sharing pane) where it says, rather clearly, "Computer name:". In my case I have "Stomp" there. Guess what, "Stomp" is what it's called at login.

[ Reply to This | # ]
Unless you are scripting...
Authored by: maclaw on Mar 11, '02 09:41:35PM

The article doesn't make any mention of the author's reason for tracking down this preference file, but if you are simply trying to change the name shown in the login panel, wouldn't it be easier to go to the Sharing Preference Pane and change the entry in the Computer Name field? Of course, if you are scripting some process that requires extracting the computer name automatically than I guess it is useful to know the location where this data is stored.

Forgive me if I have merely stated the obvious. I just wanted to make sure folks weren't left with the impression that manually accessing an xml document was the easiest way to change the name that appears in your login panel.

[ Reply to This | # ]
Unless you are scripting...
Authored by: outofcontrol on Mar 11, '02 10:02:57PM

I realize that the name can be easily changed in the System Preferences, and should have mentioned it as a side note. But, as you state, it is an interesting hint to show where to find the name in the system for use in scripts.

[ Reply to This | # ]
Unless you are scripting...
Authored by: rebug on Mar 12, '02 01:30:38AM

Scripting or working remotely. If all you've got is an ssh connection to a mac, this is the only way to do it.

[ Reply to This | # ]
Simpler solution..
Authored by: anrkngl on Mar 12, '02 07:38:25AM
Under most unices you can read and set your hostname with the hostname command. hostname returns your FQDN (system.domain, in my case hostname -s returns your system name (in my case lacroix) I would use hostname to set my system name to spaz. I would try this on my mac, but it's asleep and I didn't set it to wake on lan connections. oops.

[ Reply to This | # ]
Simpler solution..
Authored by: uscmacguy on Mar 12, '02 06:20:35PM

This solution only sets the hostname for the unix part of the system. The login panel and the shareing prefs part still would have what ever name is in the prefrenses.xml file

[ Reply to This | # ]
Not so simple....I think
Authored by: MacMunky on Mar 13, '02 01:16:55PM
I also use the hostname command in other unices to set the machine's name. But for some reason it hasn't worked for me in OS X. It sets the hostname temporarily but after a reboot it resets to localhost.

[ Reply to This | # ]
How to get Computer Name in 10.3
Authored by: TokyoJimu on Feb 09, '05 02:16:14PM

I've been trying to figure out how to get the "Computer Name" as set under Sharing in System Preferences in 10.3. 'hostname' returns the current FQDN of your current IP address, which isn't what I wanted.

The command I was looking for is
/usr/sbin/scutil --get LocalHostName

I'm adding it to this thread in case someone else is looking for this info.

[ Reply to This | # ]