LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-01-2010, 02:27 AM   #1
gardenair
Member
 
Registered: Oct 2004
Location: LH
Posts: 610

Rep: Reputation: 31
How to change your Hostname in RedHat Linux


Hi,
I want to change the Hostname of my Red Hat9 Linux machine using command line.
By defauly it show me as following

[root@localhost root]#

I want to see it as
[root@pc1 root]#


Is there any way to change host name?

thanks in advance
garden

Last edited by gardenair; 04-01-2010 at 02:33 AM.
 
Old 04-01-2010, 02:30 AM   #2
Sayan Acharjee
Member
 
Registered: Feb 2010
Location: Chennai, India
Distribution: Manjaro
Posts: 616

Rep: Reputation: 64
Quote:
Originally Posted by gardenair View Post
Hi,
I want to change the Hostname of my RedHat Linux machine.
By defauly it show me as following

[root@localhost root]#

I want to see it as
[root@pc1 root]#


Is there any way to change host name?

thanks in advance
garden

You can issue the following command:
Quote:
#hostname Desired_Name
It is not permanent i.e., after reboot this change won't exist.
To make it permanent you need to add the following entry in /etc/sysconfig/network file:

Quote:
HOSTNAME=Desired_Name

Last edited by Sayan Acharjee; 04-01-2010 at 02:31 AM.
 
Old 04-01-2010, 03:14 AM   #3
gardenair
Member
 
Registered: Oct 2004
Location: LH
Posts: 610

Original Poster
Rep: Reputation: 31
well i have edit the network file and then reboot my Linux pc. After booting and giving my credentials it say

"Could not look up internet address for PC1.localdomain.
This will prevent GNOME from opening correctly.
it may be possible to correct the problem by adding PC1.localdomain to the file /etc/host.

Login Anyway Try again

Please help me
thanks
 
Old 04-01-2010, 03:17 AM   #4
Sayan Acharjee
Member
 
Registered: Feb 2010
Location: Chennai, India
Distribution: Manjaro
Posts: 616

Rep: Reputation: 64
Quote:
Originally Posted by gardenair View Post
well i have edit the network file and then reboot my Linux pc. After booting and giving my credentials it say

"Could not look up internet address for PC1.localdomain.
This will prevent GNOME from opening correctly.
it may be possible to correct the problem by adding PC1.localdomain to the file /etc/host.

Login Anyway Try again

Please help me
thanks

Adding this line to your /etc/hosts file will resolve this problem:
127.0.0.1 hostname
 
Old 04-01-2010, 03:21 AM   #5
prpednek
LQ Newbie
 
Registered: Mar 2010
Location: India
Distribution: RHEL
Posts: 22

Rep: Reputation: 16
Quote:
Originally Posted by sayan_acharjee View Post
Adding this line to your /etc/hosts file will resolve this problem:
127.0.0.1 hostname

Please refer to the link given below :

http://www.ducea.com/2006/08/07/how-...-linux-system/

Cheers,
Prasad.
 
Old 04-01-2010, 03:28 AM   #6
gardenair
Member
 
Registered: Oct 2004
Location: LH
Posts: 610

Original Poster
Rep: Reputation: 31
thanks for your prompt reply.
well vim show the file as

127.0.0.1 localhost.localdomain localhost


i want to edit to file but before doing any change i want to ask one thing that

should i do it with like as following


127.0.0.1 localhost.pc1 localhost
need your suggestion.
thanks once again.
 
Old 04-01-2010, 03:31 AM   #7
Sayan Acharjee
Member
 
Registered: Feb 2010
Location: Chennai, India
Distribution: Manjaro
Posts: 616

Rep: Reputation: 64
Quote:
Originally Posted by gardenair View Post
thanks for your prompt reply.
well vim show the file as

127.0.0.1 localhost.localdomain localhost


i want to edit to file but before doing any change i want to ask one thing that

should i do it with like as following


127.0.0.1 localhost.pc1 localhost
need your suggestion.
thanks once again.
You can do it like this:
Quote:
127.0.0.1 localhost.pc1
or

Quote:
127.0.0.1 localhost.pc1 localhost.pc1 localhost
 
Old 04-01-2010, 03:56 AM   #8
gardenair
Member
 
Registered: Oct 2004
Location: LH
Posts: 610

Original Poster
Rep: Reputation: 31
I have changed it as

127.0.0.1 localhost.pc1 localhost.pc1 localhost

but still viewing same alert message after rebooting my pc.
 
Old 04-01-2010, 04:52 AM   #9
Sayan Acharjee
Member
 
Registered: Feb 2010
Location: Chennai, India
Distribution: Manjaro
Posts: 616

Rep: Reputation: 64
Quote:
Originally Posted by gardenair View Post
I have changed it as

127.0.0.1 localhost.pc1 localhost.pc1 localhost

but still viewing same alert message after rebooting my pc.
Try this:
Quote:
#echo "your_machine_ip your_hostname" >> /etc/hosts
 
Old 04-01-2010, 05:27 AM   #10
gardenair
Member
 
Registered: Oct 2004
Location: LH
Posts: 610

Original Poster
Rep: Reputation: 31
well again after receiving the same alert message I press the buttn "Login anyway"

My Netword card address is 192.168.1.10

MY prompt is now

[root@pc1 root]#

[root@pc1 root]# echo 192.168.1.10 >> /etc/hosts
[root@pc1 root]#

It simply accept it with any error message.

Well I again do vim hosts

and delete 127.0.0.1 and write my LAN Ip address ,Save and quit vim ,Reboot my PC but again I see

Could not look up internet address for PC1.localdomain.
This will prevent GNOME from opening correctly.
it may be possible to correct the problem by adding PC1.localdomain to the file /etc/host.

Login Anyway Try again
When i Login anyway and use terminal it show me the prompt as

[root@pc1 root]#


oooooh what is the issue ...still yet it is not solved.
please help me

Last edited by gardenair; 04-01-2010 at 05:29 AM.
 
Old 04-01-2010, 05:31 AM   #11
Sayan Acharjee
Member
 
Registered: Feb 2010
Location: Chennai, India
Distribution: Manjaro
Posts: 616

Rep: Reputation: 64
Quote:
Originally Posted by gardenair View Post
well again after receiving the same alert message I press the buttn "Login anyway"

My Netword card address is 192.168.1.10

MY prompt is now

[root@pc1 root]#

[root@pc1 root]# echo 192.168.1.10 >> /etc/hosts
[root@pc1 root]#

It simply accept it with any error message.

Well I again do vim hosts

and delete 127.0.0.1 and write my LAN Ip address ,Save and quit vim ,Reboot my PC but again I see

"Could not look up internet address for PC1.localdomain.
This will prevent GNOME from opening correctly.
it may be possible to correct the problem by adding PC1.localdomain to the file /etc/host.

Login Anyway Try again

When i Login anyway and use terminal it show me the prompt as

[root@pc1 root]#


oooooh what is the issue ...still yet it is not solved.
please help me
The command should be
Quote:
echo "192.168.1.10 Hostname">> /etc/hosts
where Hostname should be your systems hostname.

not

Quote:
echo 192.168.1.10 >> /etc/hosts

Last edited by Sayan Acharjee; 04-01-2010 at 05:32 AM.
 
Old 04-01-2010, 07:41 AM   #12
gardenair
Member
 
Registered: Oct 2004
Location: LH
Posts: 610

Original Poster
Rep: Reputation: 31
Question

well I have done the teps which u have mention.But oops i am facing same alart message after giving my credentials.

So no solution still of my question.
 
Old 04-01-2010, 07:58 AM   #13
Sayan Acharjee
Member
 
Registered: Feb 2010
Location: Chennai, India
Distribution: Manjaro
Posts: 616

Rep: Reputation: 64
Quote:
Originally Posted by gardenair View Post
well I have done the teps which u have mention.But oops i am facing same alart message after giving my credentials.

So no solution still of my question.
Can you post your /etc/hosts file here?

Note: There should not be any space in your hostname.

Last edited by Sayan Acharjee; 04-01-2010 at 08:03 AM.
 
Old 04-02-2010, 12:40 AM   #14
gardenair
Member
 
Registered: Oct 2004
Location: LH
Posts: 610

Original Poster
Rep: Reputation: 31
My Original etc/sysconfig/network file was

vim /etc/sysconfig/network

NETWORKING=yes
HOSTNAME=localhost.localdomain


After alteration in it,it looks like

NETWORKING=yes
HOSTNAME=pc1.localdomain



My original /etc/hosts file was as following

vim /etc/hosts

#Do not remove the following line,or various program
#that require network functionaly will fail

127.0.0.1 localhost.localdomain localhost


After alteration in it,it looks like

#Do not remove the following line,or various program
#that require network functionaly will fail

192.168.1.10 localhost.pc1
192.168.1.10
192.168.1.10 PC1


Now I thinkl you can guide me in much batter way
thanks
garden
 
Old 04-05-2010, 01:10 AM   #15
Sayan Acharjee
Member
 
Registered: Feb 2010
Location: Chennai, India
Distribution: Manjaro
Posts: 616

Rep: Reputation: 64
Quote:
Originally Posted by gardenair View Post
My Original etc/sysconfig/network file was

vim /etc/sysconfig/network

NETWORKING=yes
HOSTNAME=localhost.localdomain


After alteration in it,it looks like

NETWORKING=yes
HOSTNAME=pc1.localdomain



My original /etc/hosts file was as following

vim /etc/hosts

#Do not remove the following line,or various program
#that require network functionaly will fail

127.0.0.1 localhost.localdomain localhost


After alteration in it,it looks like

#Do not remove the following line,or various program
#that require network functionaly will fail

192.168.1.10 localhost.pc1
192.168.1.10
192.168.1.10 PC1


Now I thinkl you can guide me in much batter way
thanks
garden

You should edit the files in the following way:

/etc/sysconfig/network file

Quote:
NETWORKING=yes
HOSTNAME=pc1.localdomain

/etc/hosts file:
Quote:
127.0.0.1 pc1.localdomain localhost.localdomain localhost
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
change hostname of LINUX CentOS 5 while running informix server ytd Linux - General 5 08-11-2009 02:04 AM
after hostname change, syslogd still output previous hostname to messages file tiger2000 Linux - General 3 07-22-2009 10:36 PM
Change of Hostname to Linux akhil Linux - General 5 04-29-2009 01:20 AM
Need help my linux box keep reboot after change the hostname findingnemo Linux - Newbie 2 01-06-2009 07:33 PM
Change hostname and domain in Linux AS 4.0 rajeshsfo Linux - General 1 12-14-2007 03:13 PM


All times are GMT -5. The time now is 02:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration