LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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 01-29-2002, 05:27 PM   #1
glock19
Member
 
Registered: Aug 2001
Distribution: Debian Etch
Posts: 510

Rep: Reputation: 31
sticking export $LFS in bash file


Quote:
One way to make sure that $LFS is set at all times is adding it to the /root/.bash_profile and/or /root/.bashrc file(s) so that every time you login as user root, or you 'su' to user root, the $LFS variable is set.
I need some help on how to do this. Here is what my /root/.bash_profile looks like.

Code:
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin
BASH_ENV=$HOME/.bashrc
USERNAME="root"

export USERNAME BASH_ENV PATH
Here is what my /root/.bashrc looks like:

Code:
# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
Where do I stick the export LFS=/mnt/lfs command?
 
Old 01-29-2002, 05:36 PM   #2
dj_relentless
Member
 
Registered: Jan 2002
Location: NZ, AKL
Distribution: Redhat 7.1
Posts: 168

Rep: Reputation: 30
So in your .bash_profile thing you could have
LFS=$LFS:/mnt/lfs
export LFS

think thats right..to test it just type echo $LFS and it should return /mnt/lfs..if not then I told ya wrong..
 
Old 01-29-2002, 06:22 PM   #3
glock19
Member
 
Registered: Aug 2001
Distribution: Debian Etch
Posts: 510

Original Poster
Rep: Reputation: 31
I added what you said, so now it looks like:

Code:
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin
BASH_ENV=$HOME/.bashrc
USERNAME="root"

export USERNAME BASH_ENV PATH
LFS=$LFS:/mnt/lfs
export LFS
When I type echo $LFS I get nothing in response.
 
Old 01-29-2002, 06:31 PM   #4
lfslinux
LFS Maintainer
 
Registered: Jan 2002
Location: Canmore, Alberta, Canada
Distribution: Linux From Scratch
Posts: 372

Rep: Reputation: 30
Quote:
Originally posted by glock19
I added what you said, so now it looks like:

Code:
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin
BASH_ENV=$HOME/.bashrc
USERNAME="root"

export USERNAME BASH_ENV PATH
LFS=$LFS:/mnt/lfs
export LFS
When I type echo $LFS I get nothing in response.
Depending on the way you login, sometimes .bash_profile isn't read (say when you open an xterm that file isn't read normally speaking unless you make it a socalled login shell by adding a special option to xterm).

Add it to .bashrc as well to cover all bases (at least one of those two files is read no matter what kind of terminal you open).

Btw, don't write LFS=$LFS:/mnt/lfs but just LFS=/mnt/lfs

If you were to add this to both files, then you could end up with:

LFS=/mnt/lfs:/mnt/lfs

And when you go install something, $LFS won't work as expected since the /mnt/lfs:/mnt/lfs directory doesn't exist.
 
Old 01-29-2002, 06:43 PM   #5
glock19
Member
 
Registered: Aug 2001
Distribution: Debian Etch
Posts: 510

Original Poster
Rep: Reputation: 31
Ok here is my .bashrc:
Code:
# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
LFS=/mnt/lfs
export LFS
And here is my .bash_profile:

Code:
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin
BASH_ENV=$HOME/.bashrc
USERNAME="root"

export USERNAME BASH_ENV PATH
LFS=/mnt/lfs
export LFS
When I type echo $LFS I still get nothing.
 
Old 01-29-2002, 06:52 PM   #6
lfslinux
LFS Maintainer
 
Registered: Jan 2002
Location: Canmore, Alberta, Canada
Distribution: Linux From Scratch
Posts: 372

Rep: Reputation: 30
peculiar

when you updated the two files, did you logout from the current terminal and logged in again?

Try running this (either way):
source ~/.bashrc
or
source ~/.bash_profile

then try echo $LFS again

also, look at your /etc/passwd file, look at the line for user root and check what the last field contains. Perhaps it's empty (then the line ends with a semi-colon (a : char)) or it has /bin/sh. Change it to /bin/bash and try to login again and test echo $LFS
 
Old 01-29-2002, 06:54 PM   #7
dj_relentless
Member
 
Registered: Jan 2002
Location: NZ, AKL
Distribution: Redhat 7.1
Posts: 168

Rep: Reputation: 30
type export LFS=$LFS:/mnt/lfs at the command prompt then type echo $LFS..see what you get then..
I don't think you actually need the export part in your .bash_profile
Thats what I did when I was pluttering..
are you trying to do this in your distro or your lfs system?

I usually wouldn't answer these questions cause I'm not 100% sure but no one else is..

Last edited by dj_relentless; 01-29-2002 at 06:56 PM.
 
Old 01-29-2002, 06:58 PM   #8
glock19
Member
 
Registered: Aug 2001
Distribution: Debian Etch
Posts: 510

Original Poster
Rep: Reputation: 31
Sorry guys. I logged out and logged back in, and it does work. I didn't realize I had to log out and in. Thanks for the help.
 
  


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
setenv - bash - export allelopath Linux - General 4 04-17-2005 05:38 AM
set and export using bash script acummings Linux - General 10 01-03-2005 02:22 PM
BASH export command galalleni Slackware 4 09-08-2003 12:44 AM
File permissions not sticking, DMA not working... Gveto Linux - General 11 12-17-2002 02:00 PM
BASH variable export Barbarian Programming 2 11-27-2001 08:37 PM


All times are GMT -5. The time now is 09:05 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration