r/bashtricks • u/theMcChicken247 • Sep 17 '19
Renaming a Mac Computer using a Bash Script?
Would anyone have any previous knowledge or have a compiled script of how to rename a Mac computer with a bash script? Im fairly new to scripting and any help or tips are appreciated! :D
2
Upvotes
2
u/Eight_Pride Sep 17 '19 edited Sep 17 '19
I'm not on the latest version of the OS but in previous versions you could use the scutil command. I believe you need to sudo to access it.
man scutilIn particular, you're looking for:
sudo scutil --get ComputerName
sudo scutil --get HostName
sudo scutil --get LocalHostNameThose commands should show you your hostname. You'll need to use the --set ___Name switch to make changes.
1
u/DM-Pythia Sep 17 '19
How are you renaming it w/in the script?