Topic starter
To change the host file in Red Hat Enterprise Linux (RHEL), you'll typically want to modify the /etc/hosts
file. You can do this using a text editor like vi
, nano
, or gedit
. Here's how you can do it using the vi
editor:
- Open a terminal.
- Type the following command to open the
/etc/hosts
file withvi
:
sudo vi /etc/hosts
- You'll be prompted to enter your password since you're using
sudo
to edit a system file. - Once the file is open, you'll see the contents of the
/etc/hosts
file. It will look something like this:
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
- To add or modify entries, move the cursor to the location where you want to make changes and type in the desired IP address followed by the hostname. For example:
192.168.1.10 example.com
- After making the necessary changes, press
Esc
to exit editing mode, then type:wq
and pressEnter
to save the changes and exitvi
.
Once you've saved the changes to the /etc/hosts
file, the new configurations should take effect immediately without requiring a system restart. Make sure that the changes you've made are correct to avoid any network issues.
Posted : 27/04/2024 9:29 pm