# Change Hostname

Changing the hostname in FreeBSD can be done in a few simple steps. Here’s how to do it:

## Step 1: Change the Hostname Temporarily
To change the hostname temporarily (until the next reboot), you can use the hostname command. Open a terminal and run:

```sh
sudo hostname new-hostname
```
Replace `new-hostname` with your desired hostname.

## Step 2: Change the Hostname Permanently
To make the hostname change permanent, you need to edit the `/etc/rc.conf`  file. Open the file in a text editor, such as `vi` or `nano`:

```sh
sudo vi /etc/rc.conf
```

or

```sh
sudo nano /etc/rc.conf
```

Look for a line that starts with hostname=. If it exists, change it to your new hostname. If it doesn’t exist, add the following line:

```sh
hostname="new-hostname"
```

Again, replace `new-hostname` with your desired hostname.

## Step 3: Update the /etc/hosts File
It’s also a good idea to update the /etc/hosts file to reflect the new hostname. Open the file:

```sh
sudo vi /etc/hosts
```
or

```sh
sudo nano /etc/hosts
```
Find the line that contains the old hostname and change it to the new hostname. It might look something like this:

```code
127.0.0.1   localhost
127.0.0.1   old-hostname
```
Change old-hostname to new-hostname:

```Code
127.0.0.1   localhost
127.0.0.1   new-hostname
```

## Step 4: Reboot or Restart Networking
To apply the changes, you can either reboot the system:

```sh
sudo reboot
```
Or, you can restart the networking service:

```sh
sudo service netif restart
```

## Step 5: Verify the Change
After rebooting or restarting the network, you can verify that the hostname has been changed by running:

```sh
hostname
```
This should display your new hostname.

By following these steps, you should be able to successfully change the hostname on your FreeBSD system.