> > > On Sat, 17 Jul 1999, pauljw wrote:
> > > > I did some fiddling and had to put my home (user, not root) directory
> > > > back in place from a backup. Happily, everything worked save for the
> > > > bash prompt. It looks like: bash-2.03$. It used to show the user name
> > > > and the current directory. How can I get that back?
> > > > TIA,
> > > > -Paul-

On Sun, 18 Jul 1999, Richard Myers wrote:

I had a chance to explore the PS1 variable and the startup files in 
Linux. I found a very curious entry in a file called bashrc in the
/etc directory. This is the entire file:

-------------------------------------------------------------- 
# /etc/bashrc 
# System wide functions and aliases 
# Environment stuff goes in /etc/profile

# For some unknown reason bash refuses to inherit
# PS1 in some circumstances that I can't figure out.
# Putting PS1 here ensures that it gets loaded every time.

PS1="[\u@\h \W]\\$ "

alias which="type -path"
--------------------------------------------------------------

Sooo, this is apparently where the prompt is defined. It 
sure would be interesting to know who wrote the notation
there-- anyone know if this is in a /etc/bashrc file
in RedHat Linux?

Note that the same PS1 line appears in /etc/profile
so this variable is defined twice. No harm in that, the
last definition is used by the system.

Note that \$ gives a # if you are root, otherwise it
will print a $

I don't really like the results of the line

  PS1="[\u@\h \W]\\$ "

...because I (so far) haven't needed the hostname in my
prompt. Therefore I changed my prompt to:

  PS1="[ \W ] \u \\$ "

I think it is a bit less busy.

The normal order of startup that I am familiar with 
(that is, the order in which the files are read and
executed) would be:

  /etc/profile
  ~/.bash_profile

(where ~/ represents your home directory).

  ~/.bashrc

But with a /etc/bashrc file, the order is going
to be:

  /etc/profile
  /etc/bashrc
  ~/.bash_profile
  ~/.bashrc

(again, where ~/ represents your home directory).

Therefore, you can set global system variables (that is,
variables that are defined for all users) in the two
files in /etc, and these variables can (normally) be
redefined in the users' files.

QUESTION: What is the significance of the leading . in
.bash_profile and .bashrc ???

ANSWER: It prevents the file from being displayed by
the ls statement. To see these files (if they exist),
you have to use ls -a

This is to reduce clutter, and to protect these 
important system files from careless tampering.


best wishes,

richard myers

Reply via email to