LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch
User Name
Password
Linux From Scratch This Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.

Notices


Reply
  Search this Thread
Old 10-14-2005, 09:28 PM   #1
Seph64
Member
 
Registered: Feb 2003
Distribution: Gentoo, FreeBSD, LFS
Posts: 298
Blog Entries: 21

Rep: Reputation: 30
Bash shell being displayed twice?


Err, something like that. I wish I could make the topic more specific

After building LFS, and starting working on the BLFS parts, I rebooted to my LFS base system (after re-building shadow like the book tells me to when I install PAM) in order to login as a different user to test su.

PROBLEM:

It seems my bash shell gets displayed twice, something like this:

seph64@LFS - /home/seph64:seph64@LFS - $:

Any reason why it is doing this, and what configuration file I need to edit to fix it (so far I've done everything the install book told me to)?

Thanks in advance.
 
Old 10-14-2005, 10:34 PM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
I'm guessing you messed with ~/.bash_profile or /etc/profile. Check to make sure you didn't make an "oops" when setting the PS1 environment variable.

I would bet money that in one of those files, there's a line containing something like this:
Code:
PS1="$PS1:\u@\h - \$"

Last edited by Dark_Helmet; 10-14-2005 at 11:30 PM.
 
Old 10-14-2005, 10:45 PM   #3
Seph64
Member
 
Registered: Feb 2003
Distribution: Gentoo, FreeBSD, LFS
Posts: 298

Original Poster
Blog Entries: 21

Rep: Reputation: 30
If I find something like that in one of the files specified, I should take out the extra $PS1?

I looked at the /etc/profile and /etc/bashrc

And both has something similar in the export PS1 fields.

Should only one of those files have the export?

Last edited by Seph64; 10-14-2005 at 10:52 PM.
 
Old 10-14-2005, 11:19 PM   #4
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
Yeah, sorry for leaving you hanging...

You'd want to remove the $PS1 reference in the assignment. As a safety measure, copy the line, comment the original, make changes to the copy, and see where it gets you. If all's well, delete the original.

If you'd like a second pair of eyes, go ahead and post the contents of both files. I don't think they'd be too terribly long to look at.

EDIT:
I changed the line above to use red text indicating what should probably be removed. By you can play with any of those assignments to suit yourself. Keep in mind that /etc/profile is looked at first, and then ~/.bash_profile. Also, changes you make won't be reflected until you log out, and log back in again.

Last edited by Dark_Helmet; 10-14-2005 at 11:32 PM.
 
Old 10-15-2005, 02:42 AM   #5
mr_demilord
Member
 
Registered: Sep 2005
Posts: 244

Rep: Reputation: 30
Thanks, I had the same problem and it's fixed.
 
Old 10-15-2005, 09:01 AM   #6
Seph64
Member
 
Registered: Feb 2003
Distribution: Gentoo, FreeBSD, LFS
Posts: 298

Original Poster
Blog Entries: 21

Rep: Reputation: 30
You mis understood me.

In /etc/profile there was this:

Quote:
export PS1='\u@\h:\w\$ '
That was also in /etc/bashrc, commenting out the line in /etc/bashrc did nothing. And there was nothing like that in ~/.bash_profile
 
Old 10-15-2005, 11:05 AM   #7
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
No misunderstanding

What I mentioned was a possible explanation, not necessarily the cause of your situation specifically. There's probably still some funny business going on in one of the startup files. If you want to experiment, at a command prompt, type this:
Code:
export PS1='\u@\h:\w\$ '
If executing that command fixes your prompt, then there's something wrong with bash's startup files.You'll have to hunt down where it is. With LFS, the PS1 assignment can be in any number of places: /etc/profile, /etc/bashrc, /etc/profile.d/*, ~/.bash_profile, ~/.bashrc.

Having an identical "export PS1=something" statement in multiple files won't hurt anything, but if the statement had a reference to "$PS1" in the example above, then that's a problem.

If the export command at the prompt doesn't fix your problem, then there is something really strange going on. None of the software in the LFS of BLFS books should mess with the prompt at all. If there's something non-standard that's been installed, that would be a good place to start looking through documentation.
 
Old 10-15-2005, 11:17 AM   #8
Seph64
Member
 
Registered: Feb 2003
Distribution: Gentoo, FreeBSD, LFS
Posts: 298

Original Poster
Blog Entries: 21

Rep: Reputation: 30
Nope, doesn't fix the prompt.

I looked through various files (/etc/profile, /etc/profile.d/, and the bash files) I am still puzzled why this problem exists.

I think the problem is with the /etc/profile file. as I have copied the /etc/profile from my gentoo install to the LFS install, and I don't get the problem.

I think I will post the text from the /etc/profile that the BLFS books states.

Code:
root@localhost / # cat /etc/profile.backup
# Begin /etc/profile
# Written for Beyond Linux From Scratch
# by James Robertson <jameswrobertson@earthlink.net>
# modifications by Dagmar d'Surreal <rivyqntzne@pbzpnfg.arg>

# System wide environment variables and startup programs.

# System wide aliases and functions should go in /etc/bashrc.  Personal
# environment variables and startup programs should go into
# ~/.bash_profile.  Personal aliases and functions should go into
# ~/.bashrc.

# Functions to help us manage paths.  Second argument is the name of the
# path variable to be modified (default: PATH)
pathremove () {
        local IFS=':'
        local NEWPATH
        local DIR
        local PATHVARIABLE=${2:-PATH}
        for DIR in ${!PATHVARIABLE} ; do
                if [ "$DIR" != "$1" ] ; then
                  NEWPATH=${NEWPATH:+$NEWPATH:}$DIR
                fi
        done
        export $PATHVARIABLE="$NEWPATH"
}

pathprepend () {
        pathremove $1 $2
        local PATHVARIABLE=${2:-PATH}
        export $PATHVARIABLE="$1${!PATHVARIABLE:+:${!PATHVARIABLE}}"
}

pathappend () {
        pathremove $1 $2
        local PATHVARIABLE=${2:-PATH}
        export $PATHVARIABLE="${!PATHVARIABLE:+${!PATHVARIABLE}:}$1"
}


# Set the initial path
export PATH=/bin:/usr/bin

if [ $EUID -eq 0 ] ; then
        pathappend /sbin:/usr/sbin
        unset HISTFILE
fi

# Setup some environment variables.
export HISTSIZE=1000
export HISTIGNORE="&:[bf]g:exit"
#export PS1="[\u@\h \w]\\$ "
export PS1='\u@\h:\w\$ '

for script in /etc/profile.d/*.sh ; do
        if [ -r $script ] ; then
                . $script
        fi
done

# Now to clean up
unset pathremove pathprepend pathappend

# End /etc/profile

Last edited by Seph64; 10-15-2005 at 11:23 AM.
 
Old 10-15-2005, 12:26 PM   #9
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
Execute this command at a command prompt:
Code:
grep -lr "PS1" /etc/*
My gut says there will be a file in /etc/profile.d listed. Post those file(s) if they're not too terribly long.
 
Old 10-15-2005, 12:29 PM   #10
Seph64
Member
 
Registered: Feb 2003
Distribution: Gentoo, FreeBSD, LFS
Posts: 298

Original Poster
Blog Entries: 21

Rep: Reputation: 30
Nope, only /etc/bashrc and /etc/profile
 
Old 10-15-2005, 12:36 PM   #11
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
Could you post /etc/bashrc as well?
 
Old 10-15-2005, 01:05 PM   #12
Seph64
Member
 
Registered: Feb 2003
Distribution: Gentoo, FreeBSD, LFS
Posts: 298

Original Poster
Blog Entries: 21

Rep: Reputation: 30
Code:
bash-3.00# cat /etc/bashrc
# Begin /etc/bashrc
# Written for Beyond Linux From Scratch
# by James Robertson <jameswrobertson@earthlink.net>
# updated by Bruce Dubbs <bdubbs@linuxfromscratch.org>

# Make sure that the terminal is set up properly for each shell

if [ -f /etc/profile.d/tinker-term.sh ]; then
  source /etc/profile.d/tinker-term.sh
fi

# System wide aliases and functions.

# System wide environment variables and startup programs should go into
# /etc/profile.  Personal environment variables and startup programs
# should go into ~/.bash_profile.  Personal aliases and functions should
# go into ~/.bashrc

# Provides a colored /bin/ls command.  Used in conjunction with code in
# /etc/profile.

alias ls='ls --color=auto'

# Provides prompt for non-login shells, specifically shells started
# in the X environment. [Review the LFS archive thread titled
# PS1 Environment Variable for a great case study behind this script
# addendum.]

#export PS1="[\u@\h \w]\\$ "
#export PS1='\u@\h:\w\$ '

# End /etc/bashrc
I commented out the last export PS1 thinking it might've been the problem.
 
Old 10-15-2005, 01:14 PM   #13
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
Honestly, I don't see anything wrong with those files.

If you want to find the culprit, then all I can suggest is start with your Gentoo version of /etc/profile and work your way back toward the LFS /etc/profile. Make a small change and see if it breaks. When/if it does break, it should give some idea where to look next.
 
Old 10-15-2005, 01:22 PM   #14
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
Whoa, whoa, whoa...

BLFS book, Chapter 3: "After LFS Configuration Issues"

Slightly past the middle of the page it says:
Quote:
/etc/profile.d/extra-prompt.sh

This script shows an example of a different way of setting the prompt. The normal variable, PS1, is supplemented by PROMPT_COMMAND. If set, the value of PROMPT_COMMAND is executed as a command prior to issuing each primary prompt. The sequence \e is an ESC character. \a is a BEL character. For a reference on xterm escape sequences, see http://rtfm.etla.org/xterm/ctlseq.html.

Code:
cat > /etc/profile.d/extra-prompt.sh << "EOF"
PROMPT_COMMAND='echo -ne "\e[1m${USER}@${HOSTNAME} : ${PWD}\e[0m\a"'
export PROMPT_COMMAND
EOF
The escape sequences above are BOLD, NORMAL, and BEL.
Kill that file or rename it to something other than *.sh and see if things improve.

Last edited by Dark_Helmet; 10-15-2005 at 01:24 PM.
 
Old 10-15-2005, 01:28 PM   #15
Seph64
Member
 
Registered: Feb 2003
Distribution: Gentoo, FreeBSD, LFS
Posts: 298

Original Poster
Blog Entries: 21

Rep: Reputation: 30
There's one oddity in all this. If I press up and scroll through the list of commands I used, it'll sometimes show the prompt as it should, but only til the next command.

Doesn't seem like it helps much.

Actually I just exited my chroot and re-entered the chroot, and now it appears to work.

Thanks.

Last edited by Seph64; 10-15-2005 at 01:32 PM.
 
  


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
shell error messages not displayed as a message box!!! user222 Linux - General 10 10-25-2004 01:11 AM
What is Bash shell? xailer Linux - Newbie 4 11-23-2003 09:29 AM
bash shell dawood shaheen Programming 9 08-01-2003 05:07 AM
Bash Shell triplem Linux - Software 4 04-17-2003 05:11 PM
Help!!!!! Bash Shell???? DarkHorse Linux - Newbie 7 06-04-2001 12:13 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch

All times are GMT -5. The time now is 03:22 AM.

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
Open Source Consulting | Domain Registration