But then you go to Terminal.app and realized that your prompt still has the old name :(. That is because the default terminal prompt uses the hostname. Doing above things does not change the hostname.
You could change the prompt by modifying
$PS1
variable but that will not solve the problem as the kernel hostname would still have the old name.Change the Hostname
To change it we usesysctl kern.hostname=NEW_NAME
$ hostname
Ignacio-no-MacBook-Pro.local
$ sudo sysctl kern.hostname=IgnacioMBP
kern.hostname: Ignacio-no-MacBook-Pro.local -> IgnacioMBP
$ hostname
Ignacio-MBP.localSometimes Computer name field is disabled (I think it is because of some policies in school or work computer. Maybe MDM?) With the following command the name can me changed.
$ sudo scutil --set ComputerName Ignacio-MBP $ scutil --get ComputerName
Ignacio-MBPTo confirm current value we use
hostname
command. Now we have to restart the terminal so the new hostname is read again populating $PS1
as intended :) See also:
MDLog:/sysadmin - How to change the hostname of a Linux system
1 comments :
Thanks for nice post.C programming details here
Post a Comment