Change your Mac Hostname via Terminal

Here’s how to change a Mac hostname with the command line and make it permanent:

scutil --set HostName [new hostname]

Simply replace [new hostname] with whatever you want the hostname of your Mac to be changed to.

An example would be let’s say I want to change my Mac laptop’s hostname to MacBookPro, I will use this command:

scutil --set HostName MacBookPro

(Note the “–” before set is two dashes next to each other, –set)

You will be asked for your admin password since you’re using the sudo command. After the command is executed you can verify that the changes took place by typing:
hostname

You can also set a temporary hostname change by using the following command:
sudo hostname [new hostname]
This will reset itself after your Mac reboots though, so if you want a permanent hostname change, use the scutil command instead.

That’s all there is to it. By default Mac OS X will usually assign the hostname as whatever the admin account username is. Changing your Mac’s hostname can make it easier to find your Mac on a network and to connect to.

This was completely taken from the following website; http://osxdaily.com/2010/09/06/change-your-mac-hostname-via-terminal/, but I liked the way it was put and I don’t like reinventing the wheel.

Useful “which” command

I ran across this gem just the other day and I have been working with Linux for years now.  I know I will get a lot of use out of this command.  If you would like to know the full executable path for a program in Linux, if you issue the following command in a terminal window, it returns the full path of the program executable.

which [program name]

So for example, if you are looking for the location of the guake terminal executable, the following screenshot shows the results from a Ubuntu platform.

This is definitely going to come in handy with startup programs.  See the post on Gnome 3 startup applications for information on getting to the startup programs on the Gnome 3 desktop.