Created
January 12, 2015 16:38
-
-
Save jacobsalmela/b6d3144bc01809a58797 to your computer and use it in GitHub Desktop.
Set all four OS X computer names using a script.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Bonjour name ending in .local | |
scutil --set LocalHostName "My-iMac" | |
# Friendly name shown in System Preferences > Sharing | |
scutil --set ComputerName "My-iMac" | |
# The name recognized by the hostname command | |
scutil --set HostName "My-iMac" | |
# Save the computer's serial number in a variable so it can be used in the next command. | |
serialNum=$(ioreg -l | awk '/IOPlatformSerialNumber/ { split($0, line, "\""); printf("%s\n", line[4]); }') | |
# Set the NetBIOS name as the serial number | |
defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string "$serialNum" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment