Display the current FreeBSD hostname

 

$ grep hostname /etc/rc.conf


OR


$ hostname

How to change the FreeBSD server hostname without a system restart?

Type the following commands on FreeBSD server:


$ sudo hostname new-server-name-here

Next edit the /etc/rc.conf file and update hostname variable:


$ sudo vi /etc/rc.conf

Example:


hostname="new-server-name-here"

Save and close the file. Finally, edit the /etc/hosts file and update the lines that reads your old-host-name:


$ sudo vi /etc/hosts

From:


127.0.0.1 old-host-name

To:


127.0.0.1 new-server-name-here

Save and close the file.


Hostname command options

Include domain information in the printed name. This is the default behavior:


$ hostname -f

Trim off any domain information from the printed name:


$ hostname -s

Only print domain information:


$ hostname -d

 

Was this answer helpful? 0 Users Found This Useful (0 Votes)