LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Mandriva (https://www.linuxquestions.org/questions/mandriva-30/)
-   -   New User question: Get hostname (https://www.linuxquestions.org/questions/mandriva-30/new-user-question-get-hostname-332258/)

cpopham 06-10-2005 01:14 PM

New User question: Get hostname
 
I am very new to Linux. Just installed my first Mandriva Linux 10.1 OS. Now I want to install MySQL on it. I have used mysql on Windows XP. To use one peice of software that I use with mysql, I have to have to host name or IP address of the machine running MySql. We use DHCP, so everytime the machine boots, it gets a different IP so I can not rely on the IP address. In Windows, I can just click on control panel and then system and then Computer name which is also the hostname. How do I get the Hostname/Computer name in Madrake Linus 10.1???

Thank you for the help.

Chester

kencaz 06-10-2005 01:33 PM

You can use:

hostname
uname -a

for Network info:
netstat -nr
ifconfig -a

Just a few ways to do it...

KC

Feebles 06-10-2005 01:34 PM

Aloha,

If you just want the IP address of the machine you're on, use 'ifconfig <interface>' (most likely eth0). That will give you a whole slew of information, including the IP address. If you the need the hostname as well, you can use the command 'hostname' with various options. Type 'man hostname' for more info. Shout if that doesn't work for you.

-Feebles

cpopham 06-10-2005 01:57 PM

Thank you for the help!!!

Chester

mhearne 06-12-2005 10:56 PM

Simply typing "hostname" will give you your hostname.

Typing "hostname mercury.planet.net" (for example) will assign your hostname to 'mercury.planet.net'.

Placing all this in /etc/sysconfig/network makes it permanent. Here is mine:

NETWORKING=yes
DOMAINNAME=kc5yfl.net
HOSTNAME=proton.kc5yfl.net
FORWARD_IPV4=true

Note that this is my local network and it is not available on the Internet. However, you need to do this for your local network to make Apache and ftp work.

Don't forget your hosts file, /etc/hosts:

#127.0.0.1 localhost.localdomain localhost #sshd fails here.
127.0.0.1 proton.kc5yfl.net localhost
192.168.0.1 proton.kc5yfl.net proton
192.168.0.253 graviton.kc5yfl.net graviton
192.168.0.252 neutron.kc5yfl.net neutron
192.168.0.251 quark.kc5yfl.net quark
192.168.0.250 photon.kc5yfl.net photon
192.168.0.249 meson.kc5yfl.net meson
192.168.0.248 lepton.kc5yfl.net lepton

My other machines are named for atomic particles, but you can use the Table of Elements (common) or the Moons of the Solar System (I think there are 160 odd).

Try not to assign user names for machine names, or your users/passwords will start getting confused with your machine/domain names.

Each machine has to have a name, and then you must also name your network. And since you are a network, then .net is obvious.

HTH

Michael


All times are GMT -5. The time now is 07:01 AM.