FreeBSD Linux Change Hostname

This post will guide you how to change hostname in FreeBSD system. You can directly run the hostname command to get the name of the current system. and you can also set the hostname with the hostname command. If you want to retain the hostname setting after rebooting, you should be better to modify the /etc/rc.conf config file.

Show the current FreeBSD Hostname

If you want to get the current hostname in FreeBSD system, you can use one of the following two command:

# grep hostname /etc/rc.conf

Or

#hostname

Change FreeBSD hostname

If you want to change the hostname of your FreeBSD system, you just do the following steps:

#1 edit the config file /etc/rc.conf via vi editor, type the command:

#vi /etc/rc.conf

#2 delete the old hostname and type the new one in the config file

#3 save and close the file.

#4 you still need to edit the /etc/hosts file to replace the old hostname with the new hostname.

#5 run the hostname command to set the new hostname for the current shell session type:

#hostname new-host-name

If you want to print the hostname with domain information, you need to use the “-f” option, type:

#hostname -f

If you want to print the short hostname, you need to use the “-s” option, type:

#hostname -s

If you want to print the domain name only, just use the “-d” option, type:

#hostname -d

 

You might also like:

Sidebar



back to top