LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 09-23-2003, 11:56 PM   #1
johnyy
Member
 
Registered: Jun 2003
Posts: 92

Rep: Reputation: 15
what are the setting ??


right now my settings for Terminal is [john@Alpha / ]$, i wonder how could I completely change host name to john@pc1, I mean all the settings, anything with the word Alpha in it's settings, I like to change to pc1, where all the config files locate ??

thanks
 
Old 09-24-2003, 01:05 AM   #2
fancypiper
LQ Guru
 
Registered: Feb 2003
Location: Sparta, NC USA
Distribution: Ubuntu 10.04
Posts: 5,141

Rep: Reputation: 58
Your host name change must be reflected in the files /etc/hosts and /etc/hostname.

The best article for modifying your prompt itsself is the Prompt Magic - Enhancing the system prompt article. Requires registration.

Last edited by fancypiper; 09-24-2003 at 01:10 AM.
 
Old 09-24-2003, 04:10 AM   #3
yapp
Member
 
Registered: Apr 2003
Location: Netherlands
Distribution: SuSE (before: Gentoo, Slackware)
Posts: 613

Rep: Reputation: 30
Your prompt variable is set in PS1 (a shell variable). That variable is usually set in /etc/profile (or a script in /etc/profile.d/) See "man bash" for details ;-) You can use special variables to include the current user, host, time, date... and such.

edit: sorry I read over the last line in the second post :-p

Here is my script that sets PS1, shows your path in the titlebar, and gives your prompt a nice color too. The prompt becomes red if you're root, and green if you're a mortal user. If you login from ssh, the color will change, and it displays your hostname instead of the tty name.

Store it somewhere as plain text file. Usually, executable scripts in /etc/profile.d/ are executed at the login. You could also create a text file somewhere (for example /etc/mystuff/promptcolor), and add "source /etc/mystuff/promptcolor" to your ~/.bashrc

Code:
if [ "$TERM" = "xterm" -o "$TERM" = "xrvt" ]; then
  ## Only update the title in an xterm.
  PS1_TITLE='\[\e]2;\u@\H:pts/\l \w\a'
# PS1_TITLE='\[\e]2;\u@\H \w\a\e[32;1m\]>\[\e[0m\]'
else
  PS1_TITLE=''
fi


if [ -z "$SSH_CONNECTION" ]; then

  # local, don't display host, but tty device.

  PS1_TTY="`tty | sed -e 's/\/dev\///'`"

  if [ "`id -u`" = "0" ]; then
    # Red root prompt
    PS1_USER='\[\033[1;31m\]\u'
    PS1_AT='\[\033[0;31m\]@'
    PS1_HOST='\[\033[1;31m\]'
  else
    # Green user prompt
    PS1_USER='\[\033[1;32m\]\u'
    PS1_AT='\[\033[0;32m\]@'
    PS1_HOST='\[\033[1;32m\]'
  fi

  PS1_HOST="$PS1_HOST$PS1_TTY"
  unset -v PS1_TTY

else

  # SSH connection, different color and display host.

  if [ "`id -u`" = "0" ]; then
    # Red/gray root prompt
    PS1_USER='\[\033[1;31m\]\u'
    PS1_AT='\[\033[0;31m\]@'
  else
    # green/gray user prompt
    PS1_USER='\[\033[1;32m\]\u'
    PS1_AT='\[\033[0;32m\]@'
  fi
  PS1_HOST='\[\033[1;30m\]\h'
fi

PS1_PATH='\[\033[1;34m\]\W'  # show dir in blue
PS1_RESET='\[\033[0m\]'


# concatenate.

PS1="$PS1_TITLE$PS1_USER$PS1_AT$PS1_HOST$PS1_RESET $PS1_PATH \\$ $PS1_RESET"
unset -v PS1_TITLE PS1_USER PS1_AT PS1_HOST PS1_PATH PS1_RESET

#PS1='\033]2;\w\007\[\033[1;32m\]\u@\h \[\033[1;34m\]\W \$ \[\033[0m\]'


# Other magical prompts:

PS2='> '
PS4='\[\033[0;34m\]+\[\033[0m\] '

export PS1 PS2 PS4

Last edited by yapp; 09-24-2003 at 04:11 AM.
 
Old 09-24-2003, 10:23 AM   #4
johnyy
Member
 
Registered: Jun 2003
Posts: 92

Original Poster
Rep: Reputation: 15
I mondify file /etc/hosts from Alpha to pc1, no it say when I type startx

coudl not look up internet address for Alpha. This will prevent GNOME from operating correctly. It may be possible to correct the problem by adding Alpha to the file /etc/hosts

so the settings didn't change..

also yapp
i try the script but it didn't work...

thanks for helping..
 
Old 09-25-2003, 02:51 AM   #5
yapp
Member
 
Registered: Apr 2003
Location: Netherlands
Distribution: SuSE (before: Gentoo, Slackware)
Posts: 613

Rep: Reputation: 30
I'm not that familiar with GNOME, but it sounds a little odd to me. However, your /etc/hosts is used to resolve that name You can store IP-addresses in there, in case you can't use DNS instead.

Microsoft Windows even has a hosts file.. with unix-style comments

Maybe should just use the tool shipped with your distribution to change your hostname. (some distro's even offer a nice graphical configuration tool)


FYI: Here is how my distribution defines/sets the hostname:
* at boot, the command /bin/hostname `cat /etc/HOSTNAME` is executed. In other words, the hostname is stored in /etc/HOSTNAME, and it's set by reading the contents, and using that as argument to /bin/hostname.
Every OS needs to read+set it's settings every time at boot. Linux is no exception, but gives you a little more insight in the details. (I'd assume Microsoft Windows does the same thing)
* To resolve my hostname, you need DNS. However "localhost", and your own name can't resolved by DNS... at least, definitely not at boot time. That's what we have the /etc/hosts file for.
* For network names, there is an /etc/networks file too.
* If your system resolves hostnames, it uses /etc/host.conf to determine the order. (look at hosts, or try DNS first)


About the prompt script: How did you try to run the script? It's supposed to work ..and what shell do you use? (most likely /bin/bash though) edit: just forgot to mention, ~/.bashrc is executed only when bash starts.. To use the new prompt directly, type "source ~/.bashrc" to run bashrc. Don't forget the "source" command; it runs the commands directly in your own shell process.

Last edited by yapp; 09-25-2003 at 02:57 AM.
 
  


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
Setting the xrandr setting permanently dazdaz Linux - Hardware 2 11-24-2005 01:57 AM
Setting up X Jaster Linux - Laptop and Netbook 10 11-21-2004 09:15 PM
Setting unusual networking setting in Mandrake zamri Linux - Networking 1 05-28-2004 06:43 AM
setting up x giddleberry Slackware 8 10-09-2003 10:48 AM
setting up X evian Linux - Laptop and Netbook 1 09-26-2003 08:03 PM


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