LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 10-24-2007, 10:32 AM   #1
rjbatchelor
LQ Newbie
 
Registered: Oct 2007
Posts: 1

Rep: Reputation: 0
Can I change my Host name? Network shows localhost


Can I change my machine name. My machine shows up in my Microsoft domain as localhost. Thanks
 
Old 10-24-2007, 11:11 AM   #2
Tortanick
Member
 
Registered: Jul 2006
Distribution: Debian Testing
Posts: 299

Rep: Reputation: 30
my hostname is defined in /etc/hostname so just edit that and you many have to reboot your networking (or everything if you prefer)

That's on Debian so depending on your Distro it may be different. (I recommend adding your distro to your user profile), if you don't have /etc/hostname on your distro googleing your distro's name followed by "hostname" is a good bet, if not, just post back here

Last edited by Tortanick; 10-24-2007 at 11:13 AM.
 
Old 10-24-2007, 11:15 AM   #3
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,085

Rep: Reputation: 398Reputation: 398Reputation: 398Reputation: 398
Yes, you can.
man hostname to find out how
cat /etc/hostname to see your current hostname
That said, I once changed my hostname and must have done something stupid because I couldn't get into my computer after a reboot, so I would advise having a "Live" (runs from the CD) distro handy, just in case. (As I remember, I had to edit /etc/hostname to get it working again)
 
Old 10-25-2007, 03:48 PM   #4
Tortanick
Member
 
Registered: Jul 2006
Distribution: Debian Testing
Posts: 299

Rep: Reputation: 30
I did man hostname, and I came to the conclusion that no one will learn how to edit their hostname with that, just edit /etc/hostname with a text editor, if you have it
 
Old 10-25-2007, 05:39 PM   #5
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,085

Rep: Reputation: 398Reputation: 398Reputation: 398Reputation: 398
Go ahead and do it then. It'll probably work fine

When I changed one of my hostnames, and I think I tried it with the hostname .... command rather than by editing the /etc/hostname file, it went badly wrong when I rebooted. I could not login as myself, or root. Not even in "System Rescue" mode. I needed a live CD to sort it out. Probably I was just stupid and made an elementary mistake. Maybe I have the error (and solution) logged somewhere, but Errr, on which PC? Nag me and I'll probably find it if necessary

My recollection is that it is best to change the hostname in /etc/hostname, and then reboot immediately. Linux (unlike windows) rarely needs a reboot, but the hostname is so vital to so many processes that it is necessary to restart most of them. The fastest and easiest way to do this is to reboot.

Do not alter the localhost address at 127.0.0.1 referenced in /etc/hosts. This is the "loopback" interface that many programs reference to access "the piece of hardware that I am currently running on". For example, I can access the cups manager by either http://localhost:631 or by http://vaio:631 ("vaio" being my laptop's hostname, but other programs / processes will expect to access this interface through the localhost interface, even though they are pointing at the same machine)

Just have a bootable rescue "live" CD to hand in case all hell lets loose (it probably won't, but you can of course come back here for help and advice if it does!)

Moral of the story: Hostname is pobably best decided at install time - it is of vital importance to many processes.

Let us know how you get on.
 
Old 10-25-2007, 06:07 PM   #6
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,036

Rep: Reputation: 96
Interesting...

It seems that I can change my hostname to newname by calling:

sudo hostname newname

However this does not modify the /etc/hostname file and when I reboot, my hostname has reverted.

In ubuntu 7.04 the file /etc/init.d/hostname.sh checks to see if /etc/hostname exists (and is not empty) and uses the hostname command passing the contents of /etc/hostname

I can't see any option with the hostname command of making the change survive a reboot, therefore you would have to edit the /etc/hostname file manually.

Last edited by Disillusionist; 10-25-2007 at 06:08 PM. Reason: Spelling mistake!
 
Old 10-25-2007, 06:16 PM   #7
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,085

Rep: Reputation: 398Reputation: 398Reputation: 398Reputation: 398
Quote:
therefore you would have to edit the /etc/hostname file manually.
Yes, this, I think, is what I had to do in the end. So try it. Then reboot (see above)
Let us know how you get on.
 
  


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
how to change user@localhost.localdomain to user@host? Kropotkin Linux - Newbie 3 11-25-2006 05:29 PM
Change mathieu@LOCALHOST (the localhost) frz Linux - Newbie 12 07-03-2006 09:04 PM
Can't connect to host localhost Scoobsky Linux - Networking 3 10-26-2005 12:47 PM
Change localhost name in username@localhost n175uj Linux - Newbie 4 07-01-2005 09:25 PM
can not logg into @localhost.myISPname only @myISPname change to /etc/host or DNS? jacobno Linux - Networking 0 03-01-2002 06:28 PM


All times are GMT -5. The time now is 06:38 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