View previous topic :: View next topic |
Author |
Message |
paulsh21 n00b
Joined: 27 Sep 2002 Posts: 41
|
Posted: Fri Nov 01, 2002 9:55 pm Post subject: ~/.bashrc |
|
|
how do i get my ~/.bashrc file read when i log in?
my username has /bin/bash in the /etc/passwd file, so i'm a bit stuck.
cheers. |
|
Back to top |
|
|
phong Bodhisattva
Joined: 16 Jul 2002 Posts: 778 Location: Michigan - 15 & Ryan
|
Posted: Fri Nov 01, 2002 9:58 pm Post subject: |
|
|
What does your ~/.bash_profile look like? IIRC, for login shells, .bashrc is sourced from .bash_profile...
Code: | # Copyright 1999-2002 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License, v2 or later
# $Header: /home/cvsroot/gentoo-src/rc-scripts/etc/skel/.bash_profile,v 1.8 2002/08/07 18:13:35 azarah Exp $
#This file is sourced by bash when you log in interactively.
[ -f ~/.bashrc ] && . ~/.bashrc |
_________________ "An empty head is not really empty; it is stuffed with rubbish. Hence the difficulty of forcing anything into an empty head."
-- Eric Hoffer |
|
Back to top |
|
|
paulsh21 n00b
Joined: 27 Sep 2002 Posts: 41
|
Posted: Fri Nov 01, 2002 10:37 pm Post subject: |
|
|
my bash_profile file has the same as yours, but my alias' and some other environment variables aren't being read.
any more ideas? |
|
Back to top |
|
|
masseya Bodhisattva
Joined: 17 Apr 2002 Posts: 2602 Location: Baltimore, MD
|
Posted: Fri Nov 01, 2002 11:05 pm Post subject: |
|
|
I have a question that's quite related to this. Does it matter what program I'm using to get a 'terminal' or do they all operate the same? How should I log into bash interactively when opening a terminal? Does it differ from terminal program to terminal program? I was attempting to determine a way to interactively log in so I can get my ~/.bash_profile sourced by logging in and running this script Code: | #! /bin/bash
if [ -z "$PS1" ]; then
echo This shell is not interactive
else
echo This shell is interactive
fi |
However, I can't seem to get any of my terminal programs to log me in interactively. Is this something that I would have to change when I'm logging into my account the very first time I log in? _________________ if i never try anything, i never learn anything..
if i never take a risk, i stay where i am.. |
|
Back to top |
|
|
phong Bodhisattva
Joined: 16 Jul 2002 Posts: 778 Location: Michigan - 15 & Ryan
|
Posted: Sat Nov 02, 2002 1:42 am Post subject: |
|
|
Ya know, to be quite honest, I'm rather confused about this too. I'm not sure exactly when /etc/bashrc, /etc/profile, ~/.bashrc and ~/.bash_profile are all supposed to get read and what the difference is supposed to be. I know /etc/profile gets read, for example when I ssh into my box, but not if I open up konsole.
paulsh21: Is this when you log on via the console, via an xterm (or equivalent), over ssh, or all of the above? I assume you've checked things like permissions on the file and typing "source .bashrc" from the command line to be doubly sure there aren't any typos or anything fouling it up... _________________ "An empty head is not really empty; it is stuffed with rubbish. Hence the difficulty of forcing anything into an empty head."
-- Eric Hoffer |
|
Back to top |
|
|
paulsh21 n00b
Joined: 27 Sep 2002 Posts: 41
|
Posted: Sat Nov 02, 2002 11:40 am Post subject: |
|
|
i'm getting the problem when i log in via the console - but none of my variables (PATH, PS1 etc) are being read when i open an xterm.
i'm searched around, and it seems as though i need to enable interactive logins for bash. how i do that, i have no idea
cheers,
paul. |
|
Back to top |
|
|
Miles Tux's lil' helper
Joined: 23 Jun 2002 Posts: 97 Location: London, UK
|
Posted: Sat Nov 02, 2002 3:38 pm Post subject: |
|
|
If you're using xterm then you need to add a flag to have it source your bash files. From the man page:
Code: | -ls
This option indicates that the shell that is
started in the xterm window will be a login shell
(i.e., the first character of argv[0] will be a
dash, indicating to the shell that it should read
the user's .login or .profile).
|
If you're running fluxbox (if you're using xterm I guess you are) edit ~/.fluxbox/menu and add the flag to the relavant startup command. |
|
Back to top |
|
|
paulsh21 n00b
Joined: 27 Sep 2002 Posts: 41
|
Posted: Sat Nov 02, 2002 4:08 pm Post subject: |
|
|
miles: that does the trick for using xterm - but gnome-terminal2 still cant be run from within a nautilus session. it complains that it cant read some file, and then quits.
I need to do "interactive login: yes" somewhere, but i don't know where. |
|
Back to top |
|
|
Miles Tux's lil' helper
Joined: 23 Jun 2002 Posts: 97 Location: London, UK
|
Posted: Sun Nov 03, 2002 11:25 am Post subject: |
|
|
Sorry Paul, I'm not familiar with gnome-terminal2, I'm almost certain it will be a program setting rather than an environment thing. |
|
Back to top |
|
|
vers_iq Apprentice
Joined: 18 May 2002 Posts: 264
|
Posted: Sun Nov 03, 2002 1:26 pm Post subject: |
|
|
there actually is no .bashrc. it was just a made up rc to work along with .bash_profile. i think .bashrc was created as a space for user to modify the bash shell profile instead of changing directy in .profile or .bash_profile (bash specified). I think RedHat was the first started using this. btw xterm dont read /etc/profile but user's specified .bash_profile unless your .bash_profile call it up, for example look at mind:
bash_profile:
Code: | # .bash_profile
PATH=$PATH:$HOME/office:/sbin:/usr/sbin:/usr/local/sbin:/usr/lib/jsdk/bin
cflags="-Os -march=pentium3 -pipe -s -fomit-frame-pointer -fforce-addr"
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
export PATH
export cflags
#export MOZILLA_FIVE_HOME=/usr/lib/mozilla
export GDK_USE_XFT=1
export AAFont="-*-fixed-*-*-*-*-*-80-*-*-*-*-*-*"
unset USERNAME
|
i use this file to set the environment i need and yes it looks for .bashrc so my .bashrc defintely means something now.
Code: | # .bashrc
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias ls='ls -a --color=tty'
alias df='df -Th'
alias s='sudo'
# Source global definitions
if [ -f /etc/profile ]; then
. /etc/profile
fi
if [ -f $HOME/colorls.sh ]; then
. $HOME/colorls.sh
fi
|
I use this one to define some functions, and yeah it sources /etc/profile to make my xterm more interactive. Actually u can just put everything in .bashrc in .bash_profile and no more calling function required. |
|
Back to top |
|
|
Larde Guru
Joined: 07 Jun 2002 Posts: 313 Location: Duesseldorf, Germany
|
Posted: Sun Nov 03, 2002 2:53 pm Post subject: |
|
|
Quote: | I'm not sure exactly when /etc/bashrc, /etc/profile, ~/.bashrc and ~/.bash_profile are all supposed to get read and what the difference is supposed to be. |
man bash tells us, which files are the files it's looking for:
When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable.
[...]
When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists.
Usually, only your first shell is the login shell, and opening further terminals without for example the -ls option or whatever that particular terminal uses, it's only reading .bashrc.
Hth,
Larde. _________________ Someday this will be my home... http://moonage.net/
I'll make you a deal
I'll say I came from Earth and my tongue is taped
|
|
Back to top |
|
|
mmealman Guru
Joined: 02 Nov 2002 Posts: 348 Location: Florida
|
Posted: Sun Nov 03, 2002 4:38 pm Post subject: SU |
|
|
phong wrote: | Ya know, to be quite honest, I'm rather confused about this too. I'm not sure exactly when /etc/bashrc, /etc/profile, ~/.bashrc and ~/.bash_profile are all supposed to get read and what the difference is supposed to be. I know /etc/profile gets read, for example when I ssh into my box, but not if I open up konsole.
|
If konsole uses SU then I don't think that uses .bash_profile. Check out the man page for su and it'll tell you it parses $HOME/.profile and /etc/login.defs |
|
Back to top |
|
|
BackSeat Apprentice
Joined: 12 Apr 2002 Posts: 242 Location: Reading, UK
|
Posted: Sun Nov 03, 2002 4:52 pm Post subject: Re: SU |
|
|
mmealman wrote: | If konsole uses SU then I don't think that uses .bash_profile. Check out the man page for su and it'll tell you it parses $HOME/.profile and /etc/login.defs |
Actually, if a user typesthen no .bash_profile is read; if they type then the .bash_profile isread (assuming bash to be the shell for that user account).
BS |
|
Back to top |
|
|
masseya Bodhisattva
Joined: 17 Apr 2002 Posts: 2602 Location: Baltimore, MD
|
Posted: Sun Nov 03, 2002 5:52 pm Post subject: |
|
|
Here's how to open a login shell (a so-called interactive shell) in three popular terminal programs:
Code: | xterm -ls
aterm -ls
Eterm -l |
_________________ if i never try anything, i never learn anything..
if i never take a risk, i stay where i am.. |
|
Back to top |
|
|
|