> > 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-

> > Verify permissions and ownership of the files you moved
> Axalon wrote:

On Sat, 17 Jul 1999, pauljw wrote:
> Did that. I didn't look at each and every file, but a good
> representative sample shows the ownership and permissions are my user
> name and are as they should be. I didn't mention that this prompt is in
> the Konsole, not the primary linux shell, so I presume it's to do with
> kde.

Greetings, everyone, I've just joined this list.

This problem is easy to fix, and gives an opportunity to learn a bit
about the startup sequence.

What you are referring to is stored in the PS1 variable. You can type
"set" and you will see a list of all your current variable settings.
The PS1 variable could be set in a number of places-- either a
global startup file, or an individual user startup file. (I don't have 
access to Linux right now, so can't be more specific about the default
installation.)

One setting for username is:

  PS1="\u--> "

The current directory is:

  PS1="\w--> "

If you combine \u and \w, you get both.

The other stuff-- in other words, the -->  can be whatever you wish.
The trailing space is a nice thing to have, however.

Soooo--- you can fix this problem easily by modifying a bash startup 
file.

Which file?

Well, first go to the command prompt and find out if it is already 
being set somewhere.

I'm doing this on a Sun system (I'm new to Linux), but it will be very
similar for you.

First check the global startup file. This is /etc profile

We are going to use the grep command from a command prompt:

  grep PS1 /etc/profile

When I do it on this Sun, it looks like this:

>>grep PS1 /etc/profile
        PS1=">>"
        PS1=">>#"
        export PS1
>>

Aha! My PS1 variable is set initially in the /etc/profile file.
This means that it is set to this value for everyone on the system.
(But each user can set it again to something different.)

Notice that the actual, global system code doesn't show up with 
grep-- we only see lines that include the "PS1" string of
characters. 

If we actually look at (my) /etc/profile file, we see this:

        PS1=">>"
        if [ "$LOGNAME" = "root" ]
        then
        PS1=">>#"
        fi
        export PS1

If you are logging in as root, you get the # in addition to 
the >> (on my system). But all that is needed to set my
user prompt would be:

       PS1=  (something)

...and, so that the change is propagated to all shell logins,

       export PS1

You may wish to check the individual user files too-- each
user can customize their own PS1 variable. To see if it is
set up in your user startup files, type:

  cd
  grep PS1 .bash_profile

...or,

  cd
  grep PS1 .bashrc

The difference between .bash_profile and .bashrc? Having
two files gives you the flexibility to separate startup
commands needed at login time (.bash_profile) from those 
you might need when you run a subshell (.bashrc). So,
I'd change .bash_profile for a user account (although
you could have different settings for subshells, too.)

I'd try this in a user login first, if you haven't had
much experience with editing text files in [U-Li]nix.
Open your .bash_profile with commands such as:

  cd
  pico .bash_profile

(substitute your favorite editor for pico, but pico
is very easy to use...)

Find out where variables are set (if you already have
a .bash_profile-- it is possible to use the /etc/profile
file for all setup).

Change the PS1 variable to what you want.

Don't forget to export it!

Some other settings for PS1:

  \d   date
  \H   hostname
  \h   abbreviated hostname
  \n   a carriage return and linefeed
  \T   time
  \t   time, another format
  \@   time, yet another format
  \u   user name
  \v   version of bash
  \V   release version of bash
  \w   current working directory
  \W   abbreviated current working directory
  \#   command number of the current prompt
  \!   command history number of the current prompt
  

best wishes,

richard myers

Reply via email to