Setting the hostname on your Mac

Setting the hostname on your Mac using scuttle

  1. Open a terminal.
  2. Type the following command to change the primary hostname of your Mac:
    sudo scutil –set HostName <new host name>
  3. Type the following command to change the Bonjour hostname of your Mac:
    sudo scutil –set LocalHostName <new host name>
  4. Optional: If you also want to change the computer name, type the following command:
    sudo scutil –set ComputerName <new name>
Like this:
 sudo scutil --get HostName
 sudo scutil --get LocalHostName
 sudo scutil --get ComputerName

How to change hostname in Linux

I’m trying to build an Oracle RAC system at work to understand how it works better. As part of this I had to build three Linux systems. I built one, then cloned it (it was a virtual machine in VMware).

But having done that, it of course kept the hostname of the first machine. So I had to work out how to change that.
It turns out that is quite easy.

  • Edit file /etc/sysconfig/network using your favourite editor. In my case is nano.
  • Look for HOSTNAME=xxxxxx
  • Change the xxxx to the name you wish to set for your computer.
  • Save the file and restart the xinetd service. (eg. type service xinetd restart in your shell)
    Or simply reboot.

via How to change hostname in Linux – Techie Corner.

Set an informative prompt

Sometime when I’m working in UNIX I get lost in the maze of directories, and sometimes I can be working on a few different systems at the same time. So i find it very helpful to set an informative prompt.
The command below, when adding to your .bash_profile or .proifle will make your prompt look something like this:

user@host:/current/directiry>

Add this to you .bash_profile or .proifle file, logout and login again.

PS1='${LOGNAME}@${HOSTNAME}:${PWD}>'; export PS1

You may need to set the HOSTNAME environment variable for the hostname part to work, like this:
HOSTNAME=`hostname`; export HOSTNAME