LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 12-24-2006, 03:19 PM   #1
JRR883
Member
 
Registered: Aug 2005
Location: God's barf bag
Distribution: Ubuntu 7.04 (Feisty Fawn)
Posts: 86

Rep: Reputation: 15
/bin/bash is schizophrenic


I'm building my own Linux distribution with Linux From Scratch, and I'm having a bit of a problem getting started. I created the LFS user, group, and directories, but I'm having trouble getting /bin/bash to work as it does on my main user. In Fedora 6, the terminal prompt is like this:
Code:
[me@localhost ~]$
With user "lfs" set to use /bin/bash (the same as my username on FC6) the terminal prompt looks like this:
Code:
lfs:~$
It doesn't sound like much of a problem, but in my username I can tell what are files and what are folders by the color it's listed as, and it's black and white here. So I decided to try /bin/csh instead of /bin/bash, since it looks like what my main account is set as. Well it works, but for some reason the "export" command doesn't work. I tried a bunch of other commands off the top of my head, but they work. So my question is, why is /bin/bash different on separate users and why can I not use the export command?
 
Old 12-24-2006, 03:36 PM   #2
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
Compare .bashrc and .bash_profile in home directories of users. And csh uses setenv instead of export, if I remember correctly.
 
Old 12-24-2006, 03:37 PM   #3
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
Quote:
So my question is, why is /bin/bash different on separate users and why can I not use the export command?
It has nothing to do with different users; it has to do with different distros and the default PS1 string (the prompt) in /etc/bashrc.

Copy the PS1 string from Fedora's /etc/bashrc, and paste it into LFS's /etc/bashrc, and you will have the same prompt.

For more on prompts, see the Bash Prompt HOWTO.
 
Old 12-24-2006, 03:44 PM   #4
JRR883
Member
 
Registered: Aug 2005
Location: God's barf bag
Distribution: Ubuntu 7.04 (Feisty Fawn)
Posts: 86

Original Poster
Rep: Reputation: 15
Thanks guys. Raskin, since you use LFS, will putting Fedora's /etc/bashrc file in $LFS screw up my build when I start compiling?
 
Old 12-24-2006, 03:49 PM   #5
Vitalie Ciubotaru
Member
 
Registered: Dec 2005
Location: Osaka, Japan
Distribution: Ubuntu Trinity
Posts: 153

Rep: Reputation: 30
Dear Sir, or Madam, since "JRR883" is not suggestive on this :-),

Your /bin/bash is NOT schizophrenic at all, it behaves exactly the way you want it to.
Well, let's take it step by step.
1. Should you have any further questions on building you Linux From Scratch [and you will, just like all the others, including myself], please post them in Forums > Linux > Linux - Distributions > LFS. THis way you have much more chances to get the answer.
2. About bash. In terminal, the command line prompt is controlled by a particular environment variable - PS1. It is set globally [for all users] in /etc/profile [more logical] or in /etc/bashrc [you can check this out on your system], but every user can set this variable to something different in ~/.bash_profile [morelogical] or in ~/.bashrc. You may want to check the value of PS1 by issuing
Code:
echo $PS1
while being logged in as different users. Further on, you can change it by simply editing the corresponding file.
3. About file colors. Usually, there's a script like /etc/profile.d/dircolors.sh, which takes care of this.
4. "export" doesn't work (?). Never heard of such problem, but you still can use "set" and "unset" instead, right?

Hope this helps
 
Old 12-24-2006, 03:50 PM   #6
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
It's property of FC more than of LFS... And I installed FC one time and killed immediately. Really, what is set there? PS* settings will do no harm. PATH can do some problems, either can LD_LIBRARY_PATH, alias for ls requiring colour on tty is harmless. So, what is there?
 
Old 12-24-2006, 04:07 PM   #7
JRR883
Member
 
Registered: Aug 2005
Location: God's barf bag
Distribution: Ubuntu 7.04 (Feisty Fawn)
Posts: 86

Original Poster
Rep: Reputation: 15
Here's /etc/bashrc:
Code:
[lfs@localhost ~]$ cat /etc/bashrc
# /etc/bashrc

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

# By default, we want this to get set.
# Even for non-interactive, non-login shells.
umask 022

# are we an interactive shell?
if [ "$PS1" ]; then
    case $TERM in
        xterm*)
                if [ -e /etc/sysconfig/bash-prompt-xterm ]; then
                        PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
                else
                PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}"; echo -ne "\007"'
                fi
                ;;
        screen)
                if [ -e /etc/sysconfig/bash-prompt-screen ]; then
                        PROMPT_COMMAND=/etc/sysconfig/bash-prompt-screen
                else
                PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}"; echo -ne "\033\\"'
                fi
                ;;
        *)
                [ -e /etc/sysconfig/bash-prompt-default ] && PROMPT_COMMAND=/etc/sysconfig/bash-prompt-default
            ;;
    esac
    # Turn on checkwinsize
    shopt -s checkwinsize
    [ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "
fi

if ! shopt -q login_shell ; then # We're not a login shell
        # Need to redefine pathmunge, it get's undefined at the end of /etc/profile
    pathmunge () {
                if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
                        if [ "$2" = "after" ] ; then
                                PATH=$PATH:$1
                        else
                                PATH=$1:$PATH
                        fi
                fi
        }

        for i in /etc/profile.d/*.sh; do
                if [ -r "$i" ]; then
                        . $i
        fi
        done
        unset i
        unset pathmunge
fi
# vim:ts=4:sw=4
And PS1 is undefined on user lfs, but is defined as [\u@\h \W]\$ on user me.

If a mod sees this, please move it to the LFS forum. I'll probably be asking more LFS questions in this thread so I don't clutter up the front page.
 
Old 12-24-2006, 04:13 PM   #8
JRR883
Member
 
Registered: Aug 2005
Location: God's barf bag
Distribution: Ubuntu 7.04 (Feisty Fawn)
Posts: 86

Original Poster
Rep: Reputation: 15
Now onto my next issue: I have the symlink of ~/tools at /tools, and I configured bintools with the --prefix=/tools switch, but when I make install, mkdir complains about too many levels of symbolic links, as shown here:
Code:
[lfs@localhost binutils-2.16.1]$ make install
/bin/sh ./mkinstalldirs /tools /tools
mkdir -p -- /tools /tools
mkdir: `/tools': Too many levels of symbolic links
mkdir: `/tools': Too many levels of symbolic links
make: *** [installdirs] Error 1
What is the problem?

Last edited by JRR883; 12-24-2006 at 04:17 PM.
 
Old 12-24-2006, 04:28 PM   #9
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
Well, and what is contents of /etc/profile.d ? /etc/bashrc seems innocent. What about ~/.bashrc , ~/.bash_profile ?

And what does
ls -ld /tools
say?
 
Old 12-24-2006, 04:37 PM   #10
JRR883
Member
 
Registered: Aug 2005
Location: God's barf bag
Distribution: Ubuntu 7.04 (Feisty Fawn)
Posts: 86

Original Poster
Rep: Reputation: 15
Code:
[lfs@localhost binutils-2.16.1]$ ls /etc/profile.d/
colorls.csh  glib2.sh               kde.sh    lang.sh   vim.sh
colorls.sh   gnome-ssh-askpass.csh  krb5.csh  less.csh  which-2.sh
cvs.sh       gnome-ssh-askpass.sh   krb5.sh   less.sh
glib2.csh    kde.csh                lang.csh  vim.csh
[lfs@localhost binutils-2.16.1]$ ls -ld /tools
lrwxrwxrwx 1 root root 6 Dec 23 23:41 /tools -> tools/
 
Old 12-24-2006, 04:41 PM   #11
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
About first - post lang.sh, less.sh, which-2.sh

About second: symlink - by definition - points to relative path written to it, so /tools points to tools as seen from it location. OOps, it points to itself. Create it with full path. It's tricky to learn that argument to ln is not the file link will point to, but text - or relative - relative to destination ! - path where link will point to.
 
Old 12-24-2006, 05:39 PM   #12
JRR883
Member
 
Registered: Aug 2005
Location: God's barf bag
Distribution: Ubuntu 7.04 (Feisty Fawn)
Posts: 86

Original Poster
Rep: Reputation: 15
Code:
[me@localhost profile.d]$ cat lang.sh 
# /etc/profile.d/lang.sh - set i18n stuff

sourced=0
for langfile in /etc/sysconfig/i18n $HOME/.i18n ; do
    [ -f $langfile ] && . $langfile && sourced=1
done    

if [ -n "$GDM_LANG" ]; then
    sourced=1
    LANG="$GDM_LANG"
    unset LANGUAGE
    if [ "$GDM_LANG" = "zh_CN.GB18030" ]; then
      export LANGUAGE="zh_CN.GB18030:zh_CN.GB2312:zh_CN"
    fi
fi

if [ "$sourced" = 1 ]; then
    [ -n "$LANG" ] && export LANG || unset LANG
    [ -n "$LC_ADDRESS" ] && export LC_ADDRESS || unset LC_ADDRESS
    [ -n "$LC_CTYPE" ] && export LC_CTYPE || unset LC_CTYPE
    [ -n "$LC_COLLATE" ] && export LC_COLLATE || unset LC_COLLATE
    [ -n "$LC_IDENTIFICATION" ] && export LC_IDENTIFICATION || unset LC_IDENTIFICATION
    [ -n "$LC_MEASUREMENT" ] && export LC_MEASUREMENT || unset LC_MEASUREMENT
    [ -n "$LC_MESSAGES" ] && export LC_MESSAGES || unset LC_MESSAGES
    [ -n "$LC_MONETARY" ] && export LC_MONETARY || unset LC_MONETARY
    [ -n "$LC_NAME" ] && export LC_NAME || unset LC_NAME
    [ -n "$LC_NUMERIC" ] && export LC_NUMERIC || unset LC_NUMERIC
    [ -n "$LC_PAPER" ] && export LC_PAPER || unset LC_PAPER
    [ -n "$LC_TELEPHONE" ] && export LC_TELEPHONE || unset LC_TELEPHONE
    [ -n "$LC_TIME" ] && export LC_TIME || unset LC_TIME
    if [ -n "$LC_ALL" ]; then
       if [ "$LC_ALL" != "$LANG" ]; then
         export LC_ALL
       else
         unset LC_ALL
       fi
    else
       unset LC_ALL
    fi
    [ -n "$LANGUAGE" ] && export LANGUAGE || unset LANGUAGE
    [ -n "$LINGUAS" ] && export LINGUAS || unset LINGUAS
    [ -n "$_XKB_CHARSET" ] && export _XKB_CHARSET || unset _XKB_CHARSET
    
    consoletype=$(/sbin/consoletype)

    if [ -n "$CHARSET" ]; then
        case $CHARSET in
            8859-1|8859-2|8859-5|8859-8|8859-15|koi*)
                if [ "$TERM" = "linux" -a "$consoletype" = "vt" ]; then
                       echo -n -e '\033(K' 2>/dev/null > /proc/$$/fd/0
                fi
                ;;
        esac
    elif [ -n "$SYSFONTACM" ]; then
        case $SYSFONTACM in
            iso01*|iso02*|iso05*|iso08*|iso15*|koi*|latin2-ucw*)
                if [ "$TERM" = "linux" -a "$consoletype" = "vt" ]; then
                        echo -n -e '\033(K' 2>/dev/null > /proc/$$/fd/0
                fi
                ;;
        esac
    fi
    if [ -n "$LANG" ]; then
      case $LANG in
        *.utf8*|*.UTF-8*)
        if [ "$TERM" = "linux" ]; then
            if [ "$consoletype" = "vt" ]; then
                case $LANG in 
                        ja*) LANG=en_US.UTF-8 ;;
                        ko*) LANG=en_US.UTF-8 ;;
                        si*) LANG=en_US.UTF-8 ;;
                        zh*) LANG=en_US.UTF-8 ;;
                        en_IN*) ;;
                        *_IN*) LANG=en_US.UTF-8 ;;
                esac
                [ -x /bin/unicode_start ] && /sbin/consoletype fg && /bin/unicode_start $SYSFONT $SYSFONTACM
            fi
        fi
        ;;
        *)
        if [ "$TERM" = "linux" ]; then
            if [ "$consoletype" = "vt" ]; then
                case $LANG in 
                        ja*) LANG=en_US ;;
                        ko*) LANG=en_US ;;
                        si*) LANG=en_US ;;
                        zh*) LANG=en_US ;;
                        en_IN*) ;;
                        *_IN*) LANG=en_US ;;
                esac
                [ -x /bin/unicode_stop ] && /sbin/consoletype fg && /bin/unicode_stop
            fi
        fi
        ;;
      esac
    fi

    unset SYSFONTACM SYSFONT
fi
unset sourced
unset langfile
[me@localhost profile.d]$ cat less.sh
# less initialization script (sh)
[ -x /usr/bin/lesspipe.sh ] && export LESSOPEN="|/usr/bin/lesspipe.sh %s"
[me@localhost profile.d]$ cat which-2.sh 
# Initialization script for bash and sh

# export AFS, if you are in AFS environment
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
Thanks, I got binutils built and installed. I'll remember to type the full path next time. This is fun! haha if that doesn't make me a geek, I don't know what does.
 
Old 12-24-2006, 05:44 PM   #13
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
Well, I guess that you can copy .bash_profile and .basrc without significant risk of breaking anything.
 
Old 12-24-2006, 11:37 PM   #14
JRR883
Member
 
Registered: Aug 2005
Location: God's barf bag
Distribution: Ubuntu 7.04 (Feisty Fawn)
Posts: 86

Original Poster
Rep: Reputation: 15
Okay, now I have a problem building GCC. I run make bootstrap and I get this:
Code:
xgcc: installation problem, cannot exec '/tools/i686-pc-linux-gnu/bin/as': Permission denied
make[2]: *** [crtbegin.o] Error 1
make[2]: Leaving directory `/home/me/gcc-build/gcc'
make[1]: *** [stage1_build] Error 2
make[1]: Leaving directory `/home/me/gcc-build/gcc'
make: *** [bootstrap] Error 2
I tried changing the permissions, but I still got that error. I didn't try building it as root, though. That's generally a bad idea. Any idea on how to get around this?
 
Old 12-25-2006, 10:54 AM   #15
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
And what are permissions for this files and what are permissions for directories on path to it? Should be a+rx both.
 
  


Reply



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
Error when starting up snort: bash:!/bin/sh/usr/local/bin/snort :Eent not found cynthia_thomas Linux - Software 1 11-11-2005 02:59 PM
What is the difference between #!/bin/bash and #!/bin/sh? mTorbin Linux - Newbie 5 11-09-2005 12:10 PM
Change /bin/bash to /bin/zsh Smokey Slackware 12 07-14-2004 01:06 AM
why did bash 2.05b install delete /bin/bash & "/bin/sh -> bash"? johnpipe Linux - Software 2 06-06-2004 06:42 PM
bin/bash:usr/bin/lpr NO SUCH FILE OR DIRECTORY Adibe_Hamm Linux - Newbie 3 10-14-2003 02:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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