LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-30-2003, 12:27 PM   #1
allelopath
Member
 
Registered: Jan 2003
Location: New Mexico
Distribution: Ubuntu 18.04.3 LTS
Posts: 539

Rep: Reputation: 30
set hostname


How do I set the name of my computer permanently?
I can do it from the command line:
>>hostname <myComputerName>

but this isn't permanent.
There must an init file I can do this, just don't know where.
 
Old 04-30-2003, 12:40 PM   #2
Nukes
Member
 
Registered: Apr 2003
Location: Scotland UK
Distribution: Gentoo
Posts: 92

Rep: Reputation: 15
look in /etc/hostname
Might be there
 
Old 04-30-2003, 12:43 PM   #3
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 270Reputation: 270Reputation: 270
Usually with Redhat it can also be specified in your network scripts or configurations in /etc/sysconfig/network

I'm not totally positive on that location, as I know Redhat has changed it around and I haven't really used Redhat since 6.2 days..
 
Old 04-30-2003, 12:51 PM   #4
allelopath
Member
 
Registered: Jan 2003
Location: New Mexico
Distribution: Ubuntu 18.04.3 LTS
Posts: 539

Original Poster
Rep: Reputation: 30
don't have /etc/hostname.
there is /etc/hosts, which contains:
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost

but form the comment, doesn't sound like i want to change it.

/etc/sysconfig/networking/profiles/default also exact same file.
 
Old 04-30-2003, 01:41 PM   #5
allelopath
Member
 
Registered: Jan 2003
Location: New Mexico
Distribution: Ubuntu 18.04.3 LTS
Posts: 539

Original Poster
Rep: Reputation: 30
think i got it.
added this line to /etc/hosts:
127.0.0.1 localhost.localdomain myComputerName

created /etc/hostname with a one line entry:
myComputerName

in /etc/sysconfig/network changed line to:
HOSTNAME=myComputerName

Createe a new file /etc/init.d/localnet containing the following:

#!/bin/sh
# Begin /etc/init.d/localnet

check_status()
{
if [ $? = 0 ]
then
echo "OK"
else
echo "FAILED"
fi
}

# not sure what these lines do, so commented them out
#echo -n "Setting up loopback device..."
#/sbin/ifconfig lo 127.0.0.1
#check_status

echo -n "Setting up hostname..."
/bin/hostname --file /etc/hostname
check_status

# End /etc/init.d/localnet
 
Old 04-30-2003, 01:43 PM   #6
bulliver
Senior Member
 
Registered: Nov 2002
Location: Edmonton AB, Canada
Distribution: Gentoo x86_64; Gentoo PPC; FreeBSD; OS X 10.9.4
Posts: 3,760
Blog Entries: 4

Rep: Reputation: 78
change this:
127.0.0.1 localhost.localdomain localhost
to this:
127.0.0.1 hostname.localdomain hostname
where 'hostname' is whatever you want. If you have a permanent ip address you will want to add that as well, ie: duplicate the same line but with your specific ip address.

Also, you should have a file /etc/sysconfig/network that looks like:
NETWORKING=yes
HOSTNAME=hostname
Put your hostname here as well.

ha ha, you got it before I could answer, good one!!
I think you wil want to uncomment those lines you commented however, some programs rely on your loopback address to work properly...

Last edited by bulliver; 04-30-2003 at 01:45 PM.
 
Old 04-30-2003, 01:49 PM   #7
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Also put "localhost" back into the hosts file.
 
Old 04-30-2003, 02:03 PM   #8
Nukes
Member
 
Registered: Apr 2003
Location: Scotland UK
Distribution: Gentoo
Posts: 92

Rep: Reputation: 15
NO no no!
You need to keep localhost in there for loopback.
[qoute]Also, you should have a file /etc/sysconfig/network that looks like:
NETWORKING=yes
HOSTNAME=hostname
Put your hostname here as well.[/quote]
That is what you need to do, if you want you can add your hostname to /etc/hosts but you must keep the 127.0.0.1 one the same, just add your hostname next to your IP addy.
 
Old 04-30-2003, 03:01 PM   #9
allelopath
Member
 
Registered: Jan 2003
Location: New Mexico
Distribution: Ubuntu 18.04.3 LTS
Posts: 539

Original Poster
Rep: Reputation: 30
Don't have a static ip addr

in /etc/hosts, i now have this:
127.0.0.1 localhost.localdomain localthost
127.0.0.1 myComputerName.localdomain myComputerName


I've uncommented the loopback lines, since apparently they're important.
 
Old 04-30-2003, 03:04 PM   #10
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Not quite - try:
Code:
127.0.0.1 localhost myComputerName.localdomain myComputerName
 
Old 04-30-2003, 06:05 PM   #11
allelopath
Member
 
Registered: Jan 2003
Location: New Mexico
Distribution: Ubuntu 18.04.3 LTS
Posts: 539

Original Poster
Rep: Reputation: 30
alright, i thinks its all straight.
thanks for everyone's help!
 
  


Reply



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
Madrake 10.1 Set Hostname + Update DNS TotalDefiance Linux - Networking 0 11-03-2004 12:27 PM
Set hostname btexpress Linux - Networking 2 06-01-2004 12:03 AM
Hostname not set with DNS server bcrisler Linux - Networking 3 03-18-2004 02:38 PM
Easy Question - set hostname in RH 9 kkempter Linux - Software 2 05-23-2003 03:49 PM
Want to set up a new domain name and hostname? hamster Linux - Networking 6 04-06-2003 12:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:53 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
Open Source Consulting | Domain Registration