I am very confused about the login script for bash. I have always used ~/.bash_profile to configure my bash shell. Now I am on a new system just as a user: I am not root. This system was originally using tcsh shell and I changed it to bash using the command ypchsh to /bin/sh, but it does not load my bash login configuration file and not even .bashrc. But if I type just


in my terminal, my login file is loaded. What should I do to load it on login?

sample of my .profile:

# .bash_profile

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

 # User specific environment and startup programs

 export PATH

 source $HOME/script.sh

  • Have you checked if shell changed? Try getent passwd `whoami` or just ps right after login. – rush Nov 29 '12 at 10:42
  • I have printed echo $SHELL and the result is /bin/sh – simona Nov 29 '12 at 10:43
  • This may or may not help: Which setup files should be used for setting up environment variables with bash? What distribution are you running? How do you log in (text mode, GUI, remotely? If GUI, what program do you type your password into?)? If you run a desktop environment after loggin in, which one? – Gilles Nov 29 '12 at 22:47
  • I am running scientific linux release 5.8. I log in with a GUI and I use gnome – simona Dec 4 '12 at 17:28

On some systems, /bin/sh is not bash (e.g. on Ubuntu, it is /bin/dash). Set your .profile for /bin/sh, use .bash_profile only for /bin/bash.

  • I have tried, it doesn't work – simona Nov 29 '12 at 15:43
  • @simona: What distribution do you use? How do you log in? – choroba Nov 29 '12 at 15:45
  • it is called scientific linux release 5.8 (Boron), I log in graphically – simona Nov 29 '12 at 17:38
  • @simona What did you try, what doesn't work? – Gilles Nov 29 '12 at 22:45
  • in effect it works, because it defines the variables I define in .profile and execute a script. but it looks like it does not load the configurations for the shell I put in .bashrc and the aliases that are defined there. I put my .profile in the main question, for reference – simona Dec 4 '12 at 17:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.