How To Change The Hostname On A FreeBSD Machine?
The hostname is the name given to a computer so that it could be identified uniquely when connected to a network. The installer asks and setup the hostname while installing FreeBSD in a system.
Sometimes you may want to change the hostname after installing FreeBSD operating system to somewhat relevant to the service running on it or something else.
This article shows exactly how you can change the hostname of a FreeBSD machine.
How to check the hostname in FreeBSD
There are various ways to find the hostname of a FreeBSD machine. You can check it in your terminal, see the image below –
The highlighted part of this image that is the string “srvr02” is the hostname.
The other way is to use hostname command in your terminal to find the hostname on FreeBSD. If you run hostname command without any argument, it will display the hostname –
As you can see in the above image srvr02 is the hostname.
How to change the hostname for the current session only
If you want to change the hostname for the current session only then execute the following command in your terminal –
For example –
Once this command is executed this will immediately change the current hostname srvr02 to ftp-server. When you log out or reboot the system, the hostname will change to the previous one i.e. srvr02.
Now you can check the hostname by running –
How to change the hostname permanently
To make changes permanent across reboots, you need to edit the file
/etc/rc.conf and also you need to replace any occurrence of hostname from
/etc/rc.conf using a text editor –
And modify the given hostname to –
For example –
/etc/hosts file by using –
Here find and change any occurrence of the old hostname to the new one, finally save the changes and exit from the editor.
Hostname command options in FreeBSD
You can use the following command-line options with hostname command in FreeBSD –
-f – Includes domain name information in printed name, this is the default behavior
-s – Trim off any domain information from the printed name
-d – Using this will print domain information only
To know more about hostname see its manual page by running –
Also, see the system configuration information by using-
You might also like
This post was last updated on October 15th, 2020 at 01:00 amFreeBSD provides various tools as a part of its base system. In FreeBSD, there are two ways to install
This post was last updated on August 1st, 2020 at 09:11 amIn Unix like operating systems, a shell is a program that interprets the command, executes, takes input(s), and prints
This post was last updated on August 1st, 2020 at 10:19 amFreeBSD operating system has an extra security feature for files called file flags. It provides additional control over files,