Linux is a very powerful operating system, you can easily communicate with the Linux using the hostname. You can easily customize the hostname with different settings customizations.

Changing the hostname requires you to perform different customizations with the Root folder. Follow the given steps to customize the hostname.

Changing Hostname in Linux

You need to have a program known as “Hostname”. it is a small utility that allows the users to easily swap and change the hostname of the system. It is very quick and easy to customize the hostname as well as change the IP address of the hostname.

All you need to open the Terminal using Ctrl + Shift = T or Ctrl + Alt + T and follow the instructions according to the system.

Customize the Hostname in Ubuntu

sudo apt install hostname

Customize the Hostname in Debian

sudo apt-get install hostname

Customize the Hostname in Fedora

sudo dnf install hostname

Customize the Hostname in OpenSUSE

sudo zypper install hostname

Customize the Hostname in Generic Linux

For customizing the Hostname in the Generic Linux, you need to do it with the Hostname Utility. Hostname requires working in the terminal and it requires root privileges. Open the system directory and gain root access with the su command or sudo -s to access the root.

su -


sudo -s

Change the hostname on the machine with the command:

hostname -b new hostname

After making the changes, confirm the new hostname and restart Linux. It is also possible to Set hostname with file. You need to open the terminal and gain the root access with su and sudo -s.

Create the hostname text file with the touch command.

touch /home/username/hostname-file

Now open the hostname file in the Nano text editor.

nano -w /home/username/hostname-file

Paste the new hostname in Nano text editor using Ctrl + Shift + V on the key to paste and save Ctrl + O and Ctrl + X to save the file.

Now change the hostname with:

hostname -i hostname-file

Another way is to use command

Modify /etc/hostname file

It directly modifies the file directly in the /etc/hostname file. Now edit the file from the terminal. Now gain the root access using su or sudo -s command.

Open the hostname from /etc/hostname file in Nano text editor with the command:

nano -w /etc/hostname

Erase the existing hostname from the file and when the hostname is deleted, add a new hostname.

Changing Hostname from File

Save the file with the Nano text editor. Press Ctrl + O to save the file and Ctrl + X to close the file.


Leave a Reply

Your email address will not be published. Required fields are marked *