LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 11-21-2003, 03:40 PM   #1
schatoor
Senior Member
 
Registered: Jul 2002
Location: a tiny place caled hendrik ido ambacht in the netherlands
Distribution: SuSE, debian, slackware, lfs
Posts: 1,358

Rep: Reputation: 45
setting "hostname"


Hi, I just installed SuSE linux 9.0 . My prompt looks like:

"sohail@kf-hi-tg01-0983:~>"

I want it to look like

"[sohail@linux ~] >"

I know I have to mess with the PS1 enviroment variable. That is set in /etc/bash.bashrc . Only in suse, that file is much more complicated then what I am used tot seeing. So instead of messing in there, I want to change my hostname from "kf-hi-tg01-0983" to "linux"
How do I do that?

P.S. Don't let the fact that I am an "guru" (yeh right) fool you. Sometimes I still feel like an newbie
 
Old 11-21-2003, 03:57 PM   #2
synaptical
Senior Member
 
Registered: Jun 2003
Distribution: Mint 13/15, CentOS 6.4
Posts: 2,020

Rep: Reputation: 46
Re: setting "hostname"

Quote:
Originally posted by schatoor

P.S. Don't let the fact that I am an "guru" (yeh right) fool you. Sometimes I still feel like an newbie
i hear you on that.

i only used SuSe for about an hour 3 months ago -- but can't you just change the hostname in the /etc/hosts file?
 
Old 11-21-2003, 04:08 PM   #3
fancypiper
Guru
 
Registered: Feb 2003
Location: Sparta, NC USA
Distribution: Ubuntu 10.04
Posts: 5,141

Rep: Reputation: 57
What is in your files /etc/hosts and /etc/hostname?

To customize your prompt, see the link referenced in my .bashrc file.
Code:
# Celeron 850 tinwhistle .bashrc file for user fancy
# User specific aliases and functions

# Change bash prompt. See the article:
# http://www-106.ibm.com/developerwork.../l-tip-prompt/
export PS1='\d \@ \[\e[32;1m\]\u\[\e[34;1m\]@\[\e[36;1m\]\H \[\e[34;1m\]\w\[\e[32;1m\]$ \[\e[0m\]'
# For the root account use this
# export PS1='\d \@ \[\e[31;1m\]\u\[\e[34;1m\]@\[\e[36;1m\]\H \[\e[34;1m\]\w\[\e[31;1m\] # \[\e[0m\]'

# Set paths
alias path='echo -e ${PATH//:/\\n}'

# Allow local users to use my X session
# xhost +local:

# Dialup, start fetchmail daemon and startx
alias x='/sbin/ifup ppp0;fetchmail -d 300;startx'

# Alter the ls command
alias ls='ls -ac'
alias lls='ls -lac'

# Become system administrator
alias god='su -'

# Connect/disconnect the internet by modem
alias dial='/sbin/ifup ppp0'
alias hangup='/sbin/ifdown ppp0'

# Launch links with my linux links page
alias links='links /home/fancy/bookmarks.html'

# Power down/reboot
alias off='shutdown -h now'
alias boot='shutdown -r now'

# For nano editor because I forget which one I use in which distro
alias pico='nano -w'
alias nano='nano -w'

# for launching window manager/desktop environments from console login
alias a='echo DESKTOP=AfterStep > ~/.desktop;startx'
alias ice='echo DESKTOP=icewm > ~/.desktop;startx'
alias kde='echo DESKTOP=KDE3 > ~/.desktop;startx'
alias wm='echo DESKTOP=WindowMaker > ~/.desktop;startx'
alias sf='echo DESKTOP=Sawfish > ~/.desktop;startx'
alias g='echo DESKTOP=Gnome > ~/.desktop;startx'
alias xf='echo DESKTOP=XFce > ~/.desktop;startx'
alias bb='echo DESKTOP=BlackBox > ~/.desktop;startx'
alias fb='echo DESKTOP=FluxBox > ~/.desktop;startx'
alias e='echo DESKTOP=Enlightenment > ~/.desktop;startx'

# Photo album slide show
alias pix='feh -r -z -F -Z -D /home/phil/Pictures'

# Script needs to be on the bottom of the file or RH updates will fsck it up
# Source global definitions
if [ -f /etc/bashrc ]; then
       	. /etc/bashrc
fi

Last edited by fancypiper; 11-21-2003 at 04:10 PM.
 
Old 11-21-2003, 04:22 PM   #4
schatoor
Senior Member
 
Registered: Jul 2002
Location: a tiny place caled hendrik ido ambacht in the netherlands
Distribution: SuSE, debian, slackware, lfs
Posts: 1,358

Original Poster
Rep: Reputation: 45
I alraigdy checked out that file (/etc/hosts). The first thing I did. It looks like

Code:
# hosts         This file describes a number of hostname-to-address
#               mappings for the TCP/IP subsystem.  It is mostly
#               used at boot time, when no name servers are running.
#               On small systems, this file can be used instead of a
#               "named" name server.
# Syntax:
#
# IP-Address  Full-Qualified-Hostname  Short-Hostname
#

127.0.0.1       localhost

# special IPv6 addresses
::1             localhost ipv6-localhost ipv6-loopback

fe00::0         ipv6-localnet

ff00::0         ipv6-mcastprefix
ff02::1         ipv6-allnodes
ff02::2         ipv6-allrouters
ff02::3         ipv6-allhosts

127.0.0.2       linux.local     linux
As you can see, it's not the file I'm looking for. There is no file /etc/hostname.

Last edited by schatoor; 11-21-2003 at 04:26 PM.
 
Old 11-21-2003, 04:32 PM   #5
fancypiper
Guru
 
Registered: Feb 2003
Location: Sparta, NC USA
Distribution: Ubuntu 10.04
Posts: 5,141

Rep: Reputation: 57
Here is /etc/hosts:
Code:
127.0.0.1	tinwhistle	localhost.localdomain   localhost
192.168.0.1     tinwhistle
192.168.0.2     uilleann
192.168.0.3     bones
and my /etc/hostname
Code:
tinwhistle
 
Old 11-21-2003, 05:49 PM   #6
synaptical
Senior Member
 
Registered: Jun 2003
Distribution: Mint 13/15, CentOS 6.4
Posts: 2,020

Rep: Reputation: 46
fancypiper: my hosts file in slack comes with this caution:

# By the way, Arnt Gulbrandsen <agulbra@nvg.unit.no> says that 127.0.0.1
# should NEVER be named with the name of the machine. It causes problems
# for some (stupid) programs, irc and reputedly talk. :^)

do you think that could cause problems with programs other than those listed? seeing that notice, i have always left my 127.0.0.1 as localhost, and assigned names to the 192.168.xxx.xxx underneath (as in your example). is that okay to do, i.e., have two "different" names for the same machine (<localhost> at 127.0.0.1 and <whatever> at 192.168.xxx.xxx)? localhost is what bash seems to default to, but i've been reluctant to change it b/c of the warning. thx.
 
Old 11-21-2003, 05:57 PM   #7
chup
Member
 
Registered: Aug 2003
Location: South Africa
Distribution: Ubuntu (Feisty)
Posts: 280

Rep: Reputation: 30
cant you just do this?
Code:
echo *your hostname* > /etc/hostname
or is that just on gentoo?
 
Old 11-21-2003, 05:57 PM   #8
fancypiper
Guru
 
Registered: Feb 2003
Location: Sparta, NC USA
Distribution: Ubuntu 10.04
Posts: 5,141

Rep: Reputation: 57
I don't use those programs, so I can't comment. My config works for Red Hat and Gentoo, but Mandrake has some screwey scripts to automate stuff that I haven't figured out how to bypass yet.
 
Old 11-21-2003, 06:13 PM   #9
schatoor
Senior Member
 
Registered: Jul 2002
Location: a tiny place caled hendrik ido ambacht in the netherlands
Distribution: SuSE, debian, slackware, lfs
Posts: 1,358

Original Poster
Rep: Reputation: 45
Quote:
cant you just do this?

code:echo *your hostname* > /etc/hostname


or is that just on gentoo?
Yes you can. I did that (or atleast something to that effect) but it didn't help.
 
Old 11-21-2003, 06:15 PM   #10
frogman
Member
 
Registered: Sep 2003
Distribution: Mandrake, Slack, Debian and PicoBSD
Posts: 181

Rep: Reputation: 30
if memory serves, can't you just type:

hostname what_the_new_hostname_should_be

or is that just on my boxes?
 
Old 11-21-2003, 06:39 PM   #11
synaptical
Senior Member
 
Registered: Jun 2003
Distribution: Mint 13/15, CentOS 6.4
Posts: 2,020

Rep: Reputation: 46
Quote:
Originally posted by frogman
if memory serves, can't you just type:

hostname what_the_new_hostname_should_be

or is that just on my boxes?
i think you're supposed to run that after you confgure your /etc/hosts file.
 
Old 11-21-2003, 06:54 PM   #12
synaptical
Senior Member
 
Registered: Jun 2003
Distribution: Mint 13/15, CentOS 6.4
Posts: 2,020

Rep: Reputation: 46
okay, here's a link that explains it pretty well.
http://www.cpqlinux.com/hostname.html
 
Old 11-21-2003, 10:23 PM   #13
mary
Member
 
Registered: Sep 2003
Distribution: Gentoo
Posts: 135

Rep: Reputation: 15
I just changed my hostname.

All I had to do was su to root and say

hostname newhostname

and it seems to have changed it OK.
 
Old 11-21-2003, 10:35 PM   #14
fancypiper
Guru
 
Registered: Feb 2003
Location: Sparta, NC USA
Distribution: Ubuntu 10.04
Posts: 5,141

Rep: Reputation: 57
It won't stay that name after re-boot, however.
 
Old 11-21-2003, 11:05 PM   #15
synaptical
Senior Member
 
Registered: Jun 2003
Distribution: Mint 13/15, CentOS 6.4
Posts: 2,020

Rep: Reputation: 46
exactly, you'll have to run the hostname command after first changing the /etc/hosts file like in fancypiper's example or in the link for it to stay after rebooting.
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SSH: how to disable "hostname reverse checking"? Alik_2005 Linux - Security 1 02-24-2005 09:25 AM
FC2 freezes on boot "setting hostname" munkymonkjr Fedora 2 10-03-2004 10:07 PM
RH 9, Netz und DNS Config, Fehler "set visible hostname" j.kopitzke Linux - Newbie 0 06-18-2003 11:31 PM
/var/log/messages contains "localhost" instead of the real hostname allel Linux - Networking 0 07-15-2002 02:49 PM
Quesiton about "FIREWALL setting" in "SETUP"--please help out yuzuohong Linux - Networking 1 05-14-2002 11:42 PM


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