To change the hostname of a FreeBSD system without rebooting, you will need to follow these steps:
Edit the /etc/rc.conf
file. Open the /etc/rc.conf
file in a text editor, such as vi
or nano
, and find the hostname
line. This line specifies the hostname of the system.
Change the hostname. Change the hostname to the new hostname that you want to use.
For example, to change the hostname to new-hostname
, you would change the hostname
line to:
hostname="new-hostname"
Save the /etc/rc.conf
file. Save the changes to the /etc/rc.conf
file and exit the text editor.
Change the hostname in the /etc/hosts
file. Open the /etc/hosts
file in a text editor, and find the line that specifies the local hostname. Change the hostname to the new hostname that you specified in the /etc/rc.conf
file.
For example, if the line reads:
127.0.0.1 localhost
You would change it to:
127.0.0.1 new-hostname
service
command:service netif restart
This will apply the changes to the hostname without rebooting the system.