# Change Hostname Of A System

Typically, hostname of a system is stored in `/etc/hostname`, and we can change that by writing a new hostname in `/etc/hostname` file.

## Method 1

1. Edit `/etc/hostname` with any text editor such as nano or vim, and replace the existing hostname -

```bash
sudo nano /etc/hostname
```

2. Save and reboot -

```bash
sudo reboot
```

## Method 2

Using `hostnamectl` command we can also set hostname, following is an example -

```
sudo hostnamectl set-hostname Dell-G15-5515
sudo reboot
```

To display current hostname, we can use `hostname` command.

***Source:*** [***CyberCiti***](https://www.cyberciti.biz/faq/ubuntu-change-hostname-command/)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://til.devjugal.com/linux/change-hostname-of-a-system.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
