Linux Hint Posted December 7, 2020 Share Posted December 7, 2020 In this quick lesson, you’ll see how the command line option is used to modify hostnames in FreeBSD. To cut to the chase, it requires you to use a variation of the hostname command, which, when issued unappended without any option, lists the current hostnames. Listing hostnames in FreeBSD with hostname command Launch the terminal and type in the command below to list the hostnames on your FreeBSD system: $ hostname Or you can use the grep utility and specify the location in the command: $ grep hostname /etc/rc.conf 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: $ sudo nano /etc/rc.conf 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: $ sudo nano /etc/hosts 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: $ sudo hostname new-name-here You should reboot anyway to see if the changes have been retained. $ sudo reboot Changing hostnames in FreeBSD without a reboot Issue the following command: $ sudo hostname freebsd11 Then make changes to the /etc/rc.conf using the command below: $ sudo nano /etc/rc.conf For better illustration, consider the following: # hostname="new-server-name-here" 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 $ sudo nano /etc/hosts Change the hostname from 127.0.0.1 old-host-name to 127.0.0.1 new-server-name-here: $ hostname command options Add the details regarding the domain with the name. use the hostname command with the –f option: $ hostname -f Use the –s option to remove the domain information: $ hostname -s To acquire details regarding the hostname, add the –d option to the hostname command: $ hostname -d To read more on the topic, visit the pages below: $ man 5 rc.conf $ man 1 hostname Wrapping up 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. View the full article Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.