LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 12-09-2007, 04:08 PM   #1
Rommeo
Member
 
Registered: Jan 2006
Posts: 48

Rep: Reputation: 15
How to change hostname ? - changing localhost


Hi

i m using slackware 12 that has a hostname "localhost". i want to change that name but dont know how. i ll be glad if anyone can help.

i have used "hostname newname " but when i restart computer it's changed into localhost again.
 
Old 12-09-2007, 04:34 PM   #2
Brian1
Guru
 
Registered: Jan 2003
Location: Seymour, Indiana
Distribution: Distribution: RHEL 5 with Pieces of this and that. Kernel 2.6.23.1, KDE 3.5.8 and KDE 4.0 beta, Plu
Posts: 5,700

Rep: Reputation: 61
I don't know slackware but see if there is a /etc/sysconfig/network file.

Brian
 
Old 12-09-2007, 04:43 PM   #3
raconteur
Member
 
Registered: Dec 2007
Location: Slightly left of center
Distribution: slackware
Posts: 276
Blog Entries: 2

Rep: Reputation: 44
localhost is a necessary name, in /etc/hosts.

To change your hostname, type as root: (for example) hostname myhostname, or add aliases to the hosts file (in addition to localhost, not instead of).

example /etc/hosts:

127.0.0.1 localhost
127.0.0.1 superlinuxbox.somedomain.net superlinuxbox

man hostname for more details.

In slackware, there is an additional file /etc/HOSTNAME
I am not sure if the hostname command changes this file, but it should match whatever is in /etc/hosts. Edit it if necessary. It should only contain the hostname and (optionally) domain, not the IP.
i.e. superlinuxbox.somedomain.net or simply superlinuxbox

Last edited by raconteur; 12-09-2007 at 04:47 PM.
 
Old 12-09-2007, 04:44 PM   #4
Rommeo
Member
 
Registered: Jan 2006
Posts: 48

Original Poster
Rep: Reputation: 15
Thank you for your reply brian..

That's the problem. There is no /etc/sysconfig/network file. Can't change it.
 
Old 12-09-2007, 04:56 PM   #5
Rommeo
Member
 
Registered: Jan 2006
Posts: 48

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by raconteur View Post
localhost is a necessary name, in /etc/hosts.

To change your hostname, type as root: (for example) hostname myhostname, or add aliases to the hosts file (in addition to localhost, not instead of).

example /etc/hosts:

127.0.0.1 localhost
127.0.0.1 superlinuxbox.somedomain.net superlinuxbox

man hostname for more details.

In slackware, there is an additional file /etc/HOSTNAME
I am not sure if the hostname command changes this file, but it should match whatever is in /etc/hosts. Edit it if necessary. It should only contain the hostname and (optionally) domain, not the IP.
i.e. superlinuxbox.somedomain.net or simply superlinuxbox
i think it's not that neccessary cause i have changed

127.0.0.1 anyname
127.0.0.1 anyname.somename.net anyname

and it works (:.

Btw there is no /etc/HOSTNAME file in slackware. i was looking for it. And as i said before "hostname newhostname" does not work when i restart pc it changed into "localhost" again .
 
Old 12-09-2007, 05:02 PM   #6
raconteur
Member
 
Registered: Dec 2007
Location: Slightly left of center
Distribution: slackware
Posts: 276
Blog Entries: 2

Rep: Reputation: 44
Quote:
Originally Posted by Rommeo View Post
i think it's not that neccessary cause i have changed

127.0.0.1 anyname
127.0.0.1 anyname.somename.net anyname

and it works (:.

Btw there is no /etc/HOSTNAME file in slackware. i was looking for it. And as i said before "hostname newhostname" does not work when i restart pc it changed into "localhost" again .
Now try to ping localhost and I bet it fails. Removing that alias will break some things. I highly recommend restoring it.

There is, or at least definitely should be a /etc/HOSTNAME file (match case) in any default slackware installation. If it doesn't exist, create it. Add a line containing anyname.somename.net and all should be well. It needs to belong to root.root with 644 permissions.
 
Old 12-09-2007, 05:15 PM   #7
Rommeo
Member
 
Registered: Jan 2006
Posts: 48

Original Poster
Rep: Reputation: 15
Yeap it works.
That was my mistake. i was looking for /etc/hostname instead of /etc/HOSTNAME ..
Now it works. My hostname is changed when i change /etc/HOSTNAME.

Thanx.
 
Old 12-09-2007, 05:58 PM   #8
rg3
Member
 
Registered: Jul 2007
Distribution: Slackware Linux
Posts: 505

Rep: Reputation: Disabled
Quote:
Now try to ping localhost and I bet it fails. Removing that alias will break some things. I highly recommend restoring it.
I second this recommendation.
 
Old 12-25-2007, 08:04 AM   #9
and_ru
Member
 
Registered: Dec 2007
Posts: 44

Rep: Reputation: 16
If you need a quick and safe way try netconfig command as root. With it you can change the name of the machine as well. Default is darkstar.

Last edited by and_ru; 12-25-2007 at 08:10 AM.
 
Old 12-25-2007, 12:19 PM   #10
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.0
Posts: 3,476

Rep: Reputation: 531Reputation: 531Reputation: 531Reputation: 531Reputation: 531Reputation: 531
Quote:
If you need a quick and safe way try netconfig command as root. With it you can change the name of the machine as well. Default is darkstar.
I wish there was a GUI way in Slackware to modify only the box host name, without having to use netconfig. By GUI I include ncurses. Yes, there is the trusty command line, which I use almost daily, but newbies are not inclined to use the command line.

Any script wizards here who can snip the host name code from netconfig and create a separate utility? The new option also should appear in pkgtools/setup. Ideally the netconfig script calls the hostname script in order not to duplicate code. I'm available for testing.
 
Old 12-25-2007, 11:07 PM   #11
rworkman
Slackware Contributor
 
Registered: Oct 2004
Location: Tuscaloosa, Alabama (USA)
Distribution: Slackware
Posts: 1,912

Rep: Reputation: Disabled
Quote:
Originally Posted by Woodsman View Post
I wish there was a GUI way in Slackware to modify only the box host name, without having to use netconfig. By GUI I include ncurses. Yes, there is the trusty command line, which I use almost daily, but newbies are not inclined to use the command line.

Any script wizards here who can snip the host name code from netconfig and create a separate utility? The new option also should appear in pkgtools/setup. Ideally the netconfig script calls the hostname script in order not to duplicate code. I'm available for testing.
Oh, come on... If a user can't be bothered to open *any* text editor to edit /etc/HOSTNAME, then I don't know what to say.

By the way, since nobody mentioned it, it's pretty simple to go ahead and change the box's hostname after editing that file too (no reboot required)
Code:
/bin/hostname $(cut -d . -f 1 /etc/HOSTNAME)
 
Old 12-31-2007, 12:12 PM   #12
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.0
Posts: 3,476

Rep: Reputation: 531Reputation: 531Reputation: 531Reputation: 531Reputation: 531Reputation: 531
Quote:
Oh, come on... If a user can't be bothered to open *any* text editor to edit /etc/HOSTNAME, then I don't know what to say.
I'm not offended or upset that most computer users avoid the command line. I use the command line and text editor regularly, but I do not expect typical computer users to follow. My non-expectation partly drives why I maintain my Slackware Desktop Enhancement Guide.

I don't expect Slackware ever to evolve into a distro that typical users embrace, but that does not mean Slackware would not benefit from certain user interface tweaks. The number one hit at my web site Slackware Desktop Enhancement Guide is how to configure the mouse scroll wheel. Mouse scroll wheels have been around for years and Slackware still does not automate that configuration. Next popular at my web site are nuisance messages, configuring the bash startup scripts, installing GRUB, configuring a GUI startup, and configuring ntpd. I interpret these repeated hits to mean that Slackware would benefit from some simple tweaks, even if those tweaks were in the ncurses pkgtools setup applets.

Although modifying the host name is straightforward for typical Slackers, I remain available for testing if anybody creates a new pkgtool applet script to configure only the host name.
 
Old 12-31-2007, 01:06 PM   #13
rworkman
Slackware Contributor
 
Registered: Oct 2004
Location: Tuscaloosa, Alabama (USA)
Distribution: Slackware
Posts: 1,912

Rep: Reputation: Disabled
Quote:
Originally Posted by Woodsman View Post
The number one hit at my web site Slackware Desktop Enhancement Guide is how to configure the mouse scroll wheel. Mouse scroll wheels have been around for years and Slackware still does not automate that configuration.
12.0 handles that just fine, or rather, the version of X in 12.0 does. Run X -configure and you'll see

Quote:
Next popular at my web site are nuisance messages, configuring the bash startup scripts, installing GRUB, configuring a GUI startup, and configuring ntpd. I interpret these repeated hits to mean that Slackware would benefit from some simple tweaks, even if those tweaks were in the ncurses pkgtools setup applets.
All of those are worth discussion and/or howto-style documents, but since they're user and/or system specific things, there's only so much that can be done in Slackware proper.
 
Old 12-31-2007, 02:10 PM   #14
Alien_Hominid
Senior Member
 
Registered: Oct 2005
Location: Lithuania
Distribution: Hybrid
Posts: 2,247

Rep: Reputation: 53
Is it something wrong with using localhost or domain name as hostname?
 
Old 12-31-2007, 09:15 PM   #15
kuitang
Member
 
Registered: Sep 2005
Distribution: Slackware, Ubuntu, OS X
Posts: 58

Rep: Reputation: 15
If there's more than one computer on the network or domain then trying to access a remote machine named 'localhost' would be a pretty frustrating exercise.
 
  


Reply

Tags
hostname, localhost, slackware


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
my hostname has been changed from my computer name to localhost johnsanty Linux - Networking 3 10-01-2006 10:21 AM
Change mathieu@LOCALHOST (the localhost) frz Linux - Newbie 12 07-03-2006 08:04 PM
Change localhost name in username@localhost n175uj Linux - Newbie 4 07-01-2005 08:25 PM
How to change prompt hostname "localhost"? Arodef Fedora 3 08-02-2004 06:45 AM
change hostname from localhost in samba Sathington Linux - Newbie 4 04-07-2004 05:27 AM


All times are GMT -5. The time now is 04:45 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration