Listing hostnames in FreeBSD with hostname command
Launch the terminal and type in the command below to list the hostnames on your FreeBSD system:
Or you can use the grep utility and specify the location in the command:
Changing hostname in FreeBSD
As stated earlier, you’ll need to add a switch to get the hostname command to change hostnames. To make these changes consistent upon restart, you’ll be editing the configuration file located in /etc/rc.conf.
To configure the /etc/rc.conf file, use the nano editor and issue the following command:
Replace the name with a new one and launch the hostname variable.
Then make changes to the /etc/hosts file, again using the nano text editor:
Edit the file to remove the name from throughout the file and replace it with the new one.
Finally, to apply changes temporarily without a reboot, type in:
You should reboot anyway to see if the changes have been retained.
Changing hostnames in FreeBSD without a reboot
Issue the following command:
Then make changes to the /etc/rc.conf using the command below:
For better illustration, consider the following:
Make sure to save the file before you exit it.
Lastly, you’ll need to modify the /etc/hosts file replaces the old hostname with the new one:s
Change the hostname from 127.0.0.1 old-host-name to 127.0.0.1 new-server-name-here:
Add the details regarding the domain with the name. use the hostname command with the –f option:
Use the –s option to remove the domain information:
To acquire details regarding the hostname, add the –d option to the hostname command:
To read more on the topic, visit the pages below:
That’s the end of the lesson. Hopefully, the instructions here worked out for you, and you’ve successfully changed the hostname on your FreeBSD system.