LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 09-10-2003, 03:36 AM   #1
hamster001
LQ Newbie
 
Registered: Sep 2003
Posts: 2

Rep: Reputation: 0
changing computer name in shell


Hello!

I'm new to linux, just installed RedHat last night & quite excited about it... I have a problem, it's that I didn't pay attention to the naming of my computer during installation, so now the shell reads something like:

[<user>@cust-64-xxx-xx-xx]$

which looks terrible! How can I change it so it reads like

[<user>@myos]$ ?


Thanks in advance!
Andy
 
Old 09-10-2003, 03:57 AM   #2
daveo
Member
 
Registered: Sep 2003
Location: Holland
Distribution: Gentoo 1.4, Slackware
Posts: 196

Rep: Reputation: 30
Re: changing computer name in shell

Quote:
Originally posted by hamster001
Hello!

I'm new to linux, just installed RedHat last night & quite excited about it... I have a problem, it's that I didn't pay attention to the naming of my computer during installation, so now the shell reads something like:

[<user>@cust-64-xxx-xx-xx]$

which looks terrible! How can I change it so it reads like

[<user>@myos]$ ?


Thanks in advance!
Andy
Have a look at /etc/hosts
 
Old 09-10-2003, 04:06 AM   #3
Demonbane
LQ Guru
 
Registered: Aug 2003
Location: Sydney, Australia
Distribution: Gentoo
Posts: 1,796

Rep: Reputation: 47
as root type:

hostname <name you want>

Then edit /etc/hosts file make sure the new hostname is binded to 127.0.0.1 otherwise some applications(for example gnome2) and services won't work properly. For redhat 9 you also need to edit /etc/sysconfig/network, because this is the file it reads when it initializes the network at start.
Lastly either restart all networking services and X or just reboot.

hope this helps
 
Old 09-10-2003, 04:13 AM   #4
daveo
Member
 
Registered: Sep 2003
Location: Holland
Distribution: Gentoo 1.4, Slackware
Posts: 196

Rep: Reputation: 30
Quote:
Originally posted by Demonbane
as root type:

hostname <name you want>

Then edit /etc/hosts file make sure the new hostname is binded to 127.0.0.1 otherwise some applications(for example gnome2) and services won't work properly. For redhat 9 you also need to edit /etc/sysconfig/network, because this is the file it reads when it initializes the network at start.
Lastly either restart all networking services and X or just reboot.

hope this helps
Hmm your right. It changes the hostname first, but does not change the domain name you're currently in. This might also be modified in /etc/hosts. Or /etc/sysconfig/network also might also change the domain name ?
 
Old 09-10-2003, 12:35 PM   #5
Skyline
Senior Member
 
Registered: Jun 2003
Distribution: Debian/other
Posts: 2,104

Rep: Reputation: 45
Check out your prompt string variable in /etc/profile

$PS1
 
Old 09-10-2003, 12:42 PM   #6
hamster001
LQ Newbie
 
Registered: Sep 2003
Posts: 2

Original Poster
Rep: Reputation: 0
thanks! i followed yours instructions and it solved the problem.
 
Old 10-24-2003, 02:28 PM   #7
cesine
LQ Newbie
 
Registered: Oct 2003
Location: montreal
Distribution: RedHat 9
Posts: 23

Rep: Reputation: 15
changed only root@mycomputer not for all users?

i followed this post, and i got to this point:
[root@mydomain user]#

but when i exited from su i was back at
[user@localhost user] $

here is what i changed my host file to:
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
127.0.0.1 mydomain.ca mydomain

my network file:
NETWORKING=yes
HOSTNAME=mydomain.ca

(i dont have a network yet cause the other computers are using windows, so i probably dont need configure this file anyway?)

should i get rid of the localhost line if im replacing it? (the note says not to, so i kept it)
if i have an ip address should i put that there instead of 127.0.0.1? can anyone point me to where i would find the ramifications of changing the ip address? or adding a line with my ip address? (i typed $ info hosts at the command line to find out what the hosts file did)

my larger goal is to make my computer act as the postmaster for any address like user@mydomain.ca im still trying to figure that one out before asking anyone

Last edited by cesine; 02-05-2004 at 07:27 PM.
 
Old 10-24-2003, 03:22 PM   #8
Osgad
LQ Newbie
 
Registered: Oct 2003
Distribution: Mandrake 9.2 Cooker
Posts: 7

Rep: Reputation: 0
I am quite a newbie but I have done some experiments with this file. At least you can edit the file and if there is a problem at boot time just undo the changes with an editor like vim and it should be back to the previous state without any trouble.
 
Old 10-29-2003, 06:12 PM   #9
skolya
LQ Newbie
 
Registered: Oct 2003
Posts: 1

Rep: Reputation: 0
I'm having a hostname problem too. When I set up this machine I installed XP first, which made me give it a name, so I typed in a random string of characters just to get past it. Then when I installed Redhat 7.3, it picked up the string as my hostname, and a lot of functions like lpd won't work because it says the hostname is "bad." I changed the name in XP to "localhost" and that worked, but Linux still gives me the bad string despite (a) changing the hostname in the shell to "localhost" and (b) setting 127.0.0.1 to localhost.localdomain in the hosts file. But when I rebooted, the random string was still coming up as my computer name. Despite these problems I've always been able to get onto the internet but I can't use my printer! Anybody got any other suggestions?
 
  


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
Changing Computer Name chris21000 Linux - Networking 1 11-28-2004 05:45 AM
Changing my computer name Maverick1182 Linux - Newbie 1 08-22-2004 12:38 PM
CHanging Computer name minm Linux - Newbie 4 08-20-2004 03:44 PM
Changing Computer Name Tank400 Mandriva 6 04-22-2004 10:47 AM
Changing Computer Name Lorddraco98 Slackware 6 04-24-2002 07:02 AM


All times are GMT -5. The time now is 02:45 PM.

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