LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Laptop and Netbook
User Name
Password
Linux - Laptop and Netbook Having a problem installing or configuring Linux on your laptop? Need help running Linux on your netbook? This forum is for you. This forum is for any topics relating to Linux and either traditional laptops or netbooks (such as the Asus EEE PC, Everex CloudBook or MSI Wind).

Notices


Reply
  Search this Thread
Old 01-13-2009, 02:07 PM   #1
riganta
Member
 
Registered: May 2007
Location: Cork (Ireland)
Distribution: Arch Xfce
Posts: 177

Rep: Reputation: 25
bash_profile in Debian Lenny


Hi Guys,

Isn't a ./bash_profile created in debian lenny at start up ?
I know that I have a /etc/profile but isn't that more system specific as opposed to user specific?
I don't even have a bashrc file but a bash.bashrc file.
What is the difference between the two ?
I need to add a few lines in my profile but I am really confused as to where.
Shall I just create ./bash_profile or inputing the few lines I have to input would sort me out?

Cheers Guys,

Riganta
 
Old 01-13-2009, 09:48 PM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
1) The files in /etc are system-wide settings, so they get loaded first. Files in a user's home directory apply only to that user, and get applied later, overriding the ones from /etc if necessary.

2) /etc/profile is the non-bash-specific login shell config. It will be read by all shells when you log directly into a system, such as when you switch to a terminal with crtl+alt+FN as opposed to calling up a console window. A standard procedure is to have the profile import your bashrc so you can have your bash settings available there too.

3) /etc/bashrc is only directly loaded by non-login shells. /etc/bash.bashrc is just Debian's way of naming the file. It's the same thing. Most people keep their system-wide aliases and settings here.

4) The file you're looking for is not "./bash_profile", it's "~/.bash_profile", a hidden file inside the home directory. Notice the period is at the beginning of the filename, not the directory separator. ./filename simply points to a file in the current directory. You need to use the "ls -a" option to see hidden files in the shell. .bash_profile is a user-level configuration for login shells. Mine contains this:
Code:
david:~$ cat ./.bash_profile
# ~/.bash_profile: executed by bash(1) for login shells.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/login.defs
#umask 022

# include .bashrc if it exists
if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

# set PATH so it includes user's private bin if it exists
if [ -d ~/bin ] ; then
    PATH=~/bin:"${PATH}"
fi
david:~$
Notice the line that will import ~/.bashrc contents if that file exists.

5) So to make a long story short, if you want your settings to be systemwide, the best option is to put them in /etc/bash.bashrc, and make sure they're sourced in /etc/profile. Similarly, if you want them for the current user only, put them in ~/.bashrc and source that file in your ~/.bash_profile.
 
Old 01-14-2009, 05:09 AM   #3
riganta
Member
 
Registered: May 2007
Location: Cork (Ireland)
Distribution: Arch Xfce
Posts: 177

Original Poster
Rep: Reputation: 25
Quote:
Originally Posted by David the H. View Post
1) The files in /etc are system-wide settings, so they get loaded first. Files in a user's home directory apply only to that user, and get applied later, overriding the ones from /etc if necessary.

2) /etc/profile is the non-bash-specific login shell config. It will be read by all shells when you log directly into a system, such as when you switch to a terminal with crtl+alt+FN as opposed to calling up a console window. A standard procedure is to have the profile import your bashrc so you can have your bash settings available there too.

3) /etc/bashrc is only directly loaded by non-login shells. /etc/bash.bashrc is just Debian's way of naming the file. It's the same thing. Most people keep their system-wide aliases and settings here.

4) The file you're looking for is not "./bash_profile", it's "~/.bash_profile", a hidden file inside the home directory. Notice the period is at the beginning of the filename, not the directory separator. ./filename simply points to a file in the current directory. You need to use the "ls -a" option to see hidden files in the shell. .bash_profile is a user-level configuration for login shells. Mine contains this:
Code:
david:~$ cat ./.bash_profile
# ~/.bash_profile: executed by bash(1) for login shells.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/login.defs
#umask 022

# include .bashrc if it exists
if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

# set PATH so it includes user's private bin if it exists
if [ -d ~/bin ] ; then
    PATH=~/bin:"${PATH}"
fi
david:~$
Notice the line that will import ~/.bashrc contents if that file exists.

5) So to make a long story short, if you want your settings to be systemwide, the best option is to put them in /etc/bash.bashrc, and make sure they're sourced in /etc/profile. Similarly, if you want them for the current user only, put them in ~/.bashrc and source that file in your ~/.bash_profile.

I did check within my home directory and found a ~/.bashrc but didn't find any ~/.bash_profile. I have added my lines in ~/.bashrc. As you said, ~/.bashrc is supposed to be source by ~/.bash_profile. Since I don't have one, it would make sense for me to create one, but I am not sure that is right way to do it in Debian ?

to make it a bit clearer, I have an app that needs to find java on my eeepc on order to run.
I ran java -version --> it did tell me that I had java install 'java version 1.5.0'
then i found out where it was installed with which java --> /usr/bin/java
so I figured that the app couldn't find it in my profile (user specific) --> the error message of the app is 'check your installation and use +javahome to specify the JDK or JRE location'

then I added the lines in ~/.bashrc as followed
export JAVA_HOME=/usr/bin/java
export PATH=$PATH:/usr/bin/java

I logged out and back in and checked with echo $JAVA_HOME and echo $PATH --> but nothing

So two questions come to my mind. Is it because I haven't source ~/.bashrc in ~/.bash_profile ? and/or do I have to uninstalled my version of Java and install the version on the Java website ?

Riganta

Last edited by riganta; 01-14-2009 at 05:52 AM. Reason: clarity
 
Old 01-14-2009, 06:28 AM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
If you don't have a ~/.bash_profile but have a ~/.profile script, then ~/.profile will be run instead. Read the beginning of "info bash". The alterate login scripts, .bashprofile, .profile and .bash_login are mentioned near the beginning. Only one is used but one may source another. /etc/profile and ~/.profile are run when you log in. The ~/.bashrc script is run when you start up a new subshell. Commands like "PATH=$PATH:/usr/local/bin" are better in ~/.profile rather than ~/.bashrc so that they run only once.

Be sure to check which startup scripts you have. Check them all, ~/.bashrc, ~/.bash_login, ~/.bash_profile and see which you have and check which has precedence.

If you can run "/bin/bash" and then you see PATH is "/usr/bin/java", then the problem is that your login script isn't sourcing .bashrc when you login.

However, it is odd that you don't have anything defined for PATH. It should have /bin/ and /usr/bin/ in the path. Check that you don't have a space after the "=" sign in the command. It would be interpreted as two commands,
PATH=
$PATH:/usr/local/bin
which would probably cause an error. But the first "PATH= " would clear the PATH variable.
 
Old 01-14-2009, 08:01 AM   #5
riganta
Member
 
Registered: May 2007
Location: Cork (Ireland)
Distribution: Arch Xfce
Posts: 177

Original Poster
Rep: Reputation: 25
Quote:
Originally Posted by jschiwal View Post
If you don't have a ~/.bash_profile but have a ~/.profile script, then ~/.profile will be run instead. Read the beginning of "info bash". The alterate login scripts, .bashprofile, .profile and .bash_login are mentioned near the beginning. Only one is used but one may source another. /etc/profile and ~/.profile are run when you log in. The ~/.bashrc script is run when you start up a new subshell. Commands like "PATH=$PATH:/usr/local/bin" are better in ~/.profile rather than ~/.bashrc so that they run only once.

Be sure to check which startup scripts you have. Check them all, ~/.bashrc, ~/.bash_login, ~/.bash_profile and see which you have and check which has precedence.

If you can run "/bin/bash" and then you see PATH is "/usr/bin/java", then the problem is that your login script isn't sourcing .bashrc when you login.

However, it is odd that you don't have anything defined for PATH. It should have /bin/ and /usr/bin/ in the path. Check that you don't have a space after the "=" sign in the command. It would be interpreted as two commands,
PATH=
$PATH:/usr/local/bin
which would probably cause an error. But the first "PATH= " would clear the PATH variable.
when I do a ls -a in my home directory, this is what I get

.profile: executed by bourne compatible login shell
script:
if [ "$BASH" ]; then
if [ -f -/.basshrc ]; then
.~/.bashrc
fi
fi

mesg n

would that mean that basically when .profile is launched, it sources .~/.bashrc ?
what would the mesg n means ?

.bashrc: executed by bash for non-login shells
script:
export PS1='\h:\w\$ '
unmask 022
export LS_OPTIONS='--color=auto'
eval "`dircolors`"
alias ls='ls $LS_OPTIONS'
alias ll='ls $LS_OPTIONS -l'
alias l='ls $LS_OPTIONS -lA'

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

export PATH
JAVA_HOME="/usr/bin/java"
export JAVA_HOME

I have added those three last lines for my apps to work with Java and for PATH but with no success
the reason why I added those lines below is that when I ran 'update-alternatives --config java' i found out that my system was using java with PATH as follow '/usr/lib/jvm/java-gcj/jre/bin/java'. So I created a simlink of that into /usr/lib/java that I placed in ~./bashrc.

Do I have to delete those lines in ~./bashrc since they don't make any difference anyways ?
In many post, I have seen people ditching java included in Debian Lenny for the one on Java website. I wouldn't want to use the one on the Java website but since nothing else as worked... I might as well give it a try.

/etc/profile: system wide .profile file for the Bourne shell and Bourne compatible shell
script:
if [ "`id -u`" -eq 0 ]; then
PATH="/usr/local/bin:/usr/bin:/bin:/usr/games"
fi

if [ "$PS1 ]; then
if [ "$BASH" ]; then
PS1='\u@\h:\w\$ '
else
if [ "`id -u`" -eq 0 ]; then
PS1='# '
else
PS1='$ '
fi
fi
fi

export PATH
JAVA_HOME="/usr/lib/java"
export JAVA_HOME

unmask 022

again, I added the lines for Java in /etc/profile since the ones in ~./bashrc didn't work out, but I don't really if that was the right way.

I am kind of lost at sea here. I am sure that there is a more simple way to make my apps find the path to Java. I thought by using JAVA_HOME I would be sorted but that is not the case. I know that I am not understanding the full picture here and I would surely appreciate some more help.

I thank you all and without you guys I wouldn't be able to move forward at all.

Riganta
 
Old 01-14-2009, 08:11 AM   #6
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Code:
.profile: executed by bourne compatible login shell
script:
if [ "$BASH" ]; then
if [ -f -/.basshrc ]; then
.~/.bashrc
fi
fi

mesg n
Your .profile script has a typo. Since ~/.basshrc doesn't exist, ~/.bashrc isn't being sourced when you log in.
Try starting a subshell (as in running konsole or xterm) and see if it runs then.

Code:
/etc/profile: system wide .profile file for the Bourne shell and Bourne compatible shell
script:
if [ "`id -u`" -eq 0 ]; then
PATH="/usr/local/bin:/usr/bin:/bin:/usr/games"
fi

if [ "$PS1 ]; then
if [ "$BASH" ]; then
PS1='\u@\h:\w\$ '
else
if [ "`id -u`" -eq 0 ]; then
PS1='# '
else
PS1='$ '
fi
fi
fi
Your /etc/profile script only sets the PATH variable for the root user.
Also the paths added aren't right. Root should have /sbin and /usr/sbin/ it it's path.

Did you rewrite /etc/profile? On some systems, there is an /etc/profile.d/ directory that contains scripts to run for the respective shells. Also, sometimes, the system expects you to leave /etc/profile alone and let it source /etc/profile.local instead.

I don't know what package would have supplied the initial /etc/profile file. On mine it is aaa_base, which may be a traditional name. You might want to find the package and extract the /etc/profile script it has.

Last edited by jschiwal; 01-14-2009 at 08:16 AM.
 
Old 01-14-2009, 08:43 AM   #7
riganta
Member
 
Registered: May 2007
Location: Cork (Ireland)
Distribution: Arch Xfce
Posts: 177

Original Poster
Rep: Reputation: 25
Quote:
Originally Posted by jschiwal View Post
Code:
.profile: executed by bourne compatible login shell
script:
if [ "$BASH" ]; then
if [ -f -/.basshrc ]; then
.~/.bashrc
fi
fi

mesg n
Your .profile script has a typo. Since ~/.basshrc doesn't exist, ~/.bashrc isn't being sourced when you log in.
Try starting a subshell (as in running konsole or xterm) and see if it runs then.

Code:
/etc/profile: system wide .profile file for the Bourne shell and Bourne compatible shell
script:
if [ "`id -u`" -eq 0 ]; then
PATH="/usr/local/bin:/usr/bin:/bin:/usr/games"
fi

if [ "$PS1 ]; then
if [ "$BASH" ]; then
PS1='\u@\h:\w\$ '
else
if [ "`id -u`" -eq 0 ]; then
PS1='# '
else
PS1='$ '
fi
fi
fi
Your /etc/profile script only sets the PATH variable for the root user.
Also the paths added aren't right. Root should have /sbin and /usr/sbin/ it it's path.

Did you rewrite /etc/profile? On some systems, there is an /etc/profile.d/ directory that contains scripts to run for the respective shells. Also, sometimes, the system expects you to leave /etc/profile alone and let it source /etc/profile.local instead.

I don't know what package would have supplied the initial /etc/profile file. On mine it is aaa_base, which may be a traditional name. You might want to find the package and extract the /etc/profile script it has.
No, I have not rewrite /etc/profile. I have fixed the typo in ./profile (thanks)
 
Old 01-14-2009, 01:31 PM   #8
riganta
Member
 
Registered: May 2007
Location: Cork (Ireland)
Distribution: Arch Xfce
Posts: 177

Original Poster
Rep: Reputation: 25
I have downloaded JAVA from the JAVA website and now I cannot even seem to install that version as well
When I run the command " fakeroot make-jpkg jre-6ull-linux-i586.bin" i get the error 'the file doesn't exists' --> I am a non root user

I am really with the java app. Anyone has any idea, that would be much appreciated

Riganta
 
Old 01-16-2009, 03:00 AM   #9
riganta
Member
 
Registered: May 2007
Location: Cork (Ireland)
Distribution: Arch Xfce
Posts: 177

Original Poster
Rep: Reputation: 25
Hi Guys,

I have finally succeeded in making my app find the path to Java binaries
all I did is add the path 'usr/lib/jvm/java-6-openjdk/jre/bin'
to my PATH in /etc/profile. So, that is sorted, but now the app start and stops and I get a very specific error message that says
'Exception in thread "main" java.awt.HeadlessException:
No X11 DISPLAY variable set, but this program performed an operation which requires it'

any insight is much appreciated.

Thank you

Riganta
 
Old 01-16-2009, 12:03 PM   #10
riganta
Member
 
Registered: May 2007
Location: Cork (Ireland)
Distribution: Arch Xfce
Posts: 177

Original Poster
Rep: Reputation: 25
I finally got it working fine. I am quite relief and the answer was insanely straightforward.
- still in /etc/profile, I have two PATH(s)
one that says

'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'

I did input my path to Java in there but that didn't work very well. Then I paid attention to the one below that says
else

'PATH='/usr/local/bin:/usr/bin:/bin:/usr/games:$PATH:/usr/lib/jvm/java-6-openjdk/jre/bin

et voila, it works perfectly

Thank you Guys for your help
 
Old 01-16-2009, 12:03 PM   #11
riganta
Member
 
Registered: May 2007
Location: Cork (Ireland)
Distribution: Arch Xfce
Posts: 177

Original Poster
Rep: Reputation: 25
I finally got it working fine. I am quite relief and the answer was insanely straightforward.
- still in /etc/profile, I have two PATH(s)
one that says

'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'

I did input my path to Java in there but that didn't work very well. Then I paid attention to the one below that says
else

'PATH='/usr/local/bin:/usr/bin:/bin:/usr/games:$PATH:/usr/lib/jvm/java-6-openjdk/jre/bin

et voila, it works perfectly

Thank you Guys for your help
 
  


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
OpenOffice 3 in Debian Lenny matiasar Debian 12 12-04-2009 08:39 AM
Kobodeluxe in Debian Lenny Cage47 Debian 3 07-10-2008 07:43 AM
Updating Debian Etch to Debian Lenny bartock Debian 4 02-09-2008 08:15 AM
Evolution in debian lenny zenlord Debian 1 01-31-2008 01:14 PM
Tuxguitar on Debian Lenny real_archer Linux - Software 5 12-16-2007 08:18 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Laptop and Netbook

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