Slackware 13.0 ~/.bash_profile not running at login
Hi,
I'm logging in as a user at run level 3. I have my .bash_profile in my home directory Code:
if [ -f ~/.bashrc ]; then Code:
echo "Running .bashrc..." However, if I explicitly 'source' the .bash_profile it works. What am I doing wrong? Thanks, Ash. |
Ok, here's what the bash man pages have to say on the subject:
Code:
INVOCATION It sounds to me like bash is not your default shell. Try Code:
echo $SHELL Code:
grep <your username> /etc/passwd | cut -d ':' -f 7 |
Hi bartonski,
Thank you very much for you suggestions. It made me look around and I finally resolved it by explicitly setting the shell. Code:
usermod -s /bin/bash <username> From what I could tell, it looked like I was in bash. I am using Xfce for the window manager. I also switched to kde but that didn't make any difference. The following is some information before I fixed it. Code:
sh-3.1$ echo $SHELL What seems a little odd though was the value of my $PS1. From the man pages Quote:
Code:
/etc/profile Code:
sh-3.1$ echo $PS1 Ash. |
The "problem" is that, once you're logged in (into X, in this case)
all subsequently invoked shells aren't login shells, so all that gets invoked for them is ~/.bashrc. |
Quote:
Quote:
|
Quote:
So it made me wonder how I created the user account. To test it, I ran the "adduser" command. After a number of prompts, it asked for the shell (with /bin/bash as the default). When I grep'd the passwd file, it had the /bin/bash entry. What could I have done because mine didn't have it? Then I realized that I might have run "useradd" instead. So I tested with it. Indeed, the shell entry is blank. Quote:
Quote:
Again, thanks for you help. I'm asking all these questions just to understand better. Regards, Ash. PS: By the way how do I get the "Originally Posted by ..." into the quote. Is that a manual copy/paste? |
Quote:
Quote:
|
Thank you!
|
Quote:
/bin/sh is typically a symbolic link to another shell. Which shell gets called varies from distro to distro. Usually this will either be ash or bash, although Debian uses a shell called dash. Here's the kicker: if called as /bin/sh, each of these shells will be called as a POSIX shell, meaning that they only execute the POSIX subset of shell commands. This is important for portability concerns. Among other things, this means that even if the symlink for /bin/sh points to /bin/bash, .bashrc won't be called for a non-login interactive shell, and .bash_profile won't be called for login shells. |
.profile is the old standard that bash uses for setting its environment variables. So create one (.profile) if it does not exist in your home directory. As bartonski has mentioned, /bin/sh does not call .bash_profile. So you will have to manually call .bash_profile inside .profile
|
All times are GMT -5. The time now is 07:51 AM. |