Blog Post Header
Tutorials December 27, 2025 47 views

How to Change Hostname and IP Address in Linux

How to Change Hostname and IP Address in Linux

How to Change Hostname and IP Address in Linux

Linux is a versatile operating system that allows users to customize various settings, including the hostname and IP address. In this tutorial, we will guide you through the process of changing the hostname and IP address in Linux.

Changing Hostname

The hostname is a label assigned to a device on a network. To change the hostname in Linux, follow these steps:

  1. Open a terminal window.
  2. Enter the following command to edit the hostname file:
sudo nano /etc/hostname

Replace the current hostname with the desired hostname and save the file.

  1. Next, edit the hosts file by entering the following command:
sudo nano /etc/hosts

Replace the current hostname with the new hostname in this file as well.

Changing IP Address

IP address is a unique numerical label assigned to each device connected to a network. Here's how you can change the IP address in Linux:

  1. Open a terminal window.
  2. Enter the following command to edit the network configuration file:
sudo nano /etc/network/interfaces

Locate the line that begins with "iface" followed by the network interface (e.g., eth0) and the word "inet." Change the IP address after "address" to the new IP address.

  1. Save the file and restart the network service by entering the following command:
sudo systemctl restart networking

Verifying Changes

To verify that the changes have been successfully applied, you can use the following commands:

  1. To check the hostname:
hostname
  1. To check the IP address:
ifconfig

Conclusion

Changing the hostname and IP address in Linux is a simple process that can be done through the terminal. By following the steps outlined in this tutorial, you can customize your system to suit your needs. Remember to verify the changes to ensure they have been applied correctly.

Author: Admin
Join Our Community

Create an account to leave comments, save your favorite posts, and get personalized recommendations.