View Full Version : [SOLVED] .bashrc/aliases not loading per SSH session

November 20th, 2012, 03:18 AM
I've just updated my server's (Ubuntu Server 12.04.01 LTS) profiles (copied/overwrote .bashrc & .bash_aliases) however when reconnecting to an SSH session as root I have to 'source ~/.bashrc' to get my aliases functioning again. The .bashrc is standard as on a fresh install apart from HISTSIZE & HISTFILESIZE, and there's no problems with my aliases file. It's pretty much a fresh install which I just reinitialized, I'm not sure what I've done wrong.

-rw-r--r-- 1 root root 1066 Nov 20 01:42 .bash_aliases
-rw------- 1 root root 327 Nov 20 02:09 .bash_history
-rw-r--r-- 1 root root 75 Nov 20 01:42 .bash_profile
-rw-r--r-- 1 root root 3486 Nov 20 02:04 .bashrc
drwx------ 2 root root 4096 Nov 20 00:27 .cache
-rw------- 1 root root 5 Nov 20 02:08 .nano_history
-rw-r--r-- 1 root root 140 Apr 19 2012 .profile

Any ideas anyone?

Oh I also can't run aliases inside of an sh (headed - #!/bin/bash) script, is that normal? I thought maybe it's related.

November 20th, 2012, 03:35 AM
On my system, /root/.bashrc is sourced from .profile (it doesn't have a .bash_profile).
I know .bashrc typically sources .bash_aliases. Which file is sourcing .bashrc? Still, you might try this

case $- in
*i*) echo "This shell is interactive";;
*) echo "This is a script";;
to see if you have an interactive shell and your .profile is indeed being sourced on login.

edit: source for the code: http://unix.stackexchange.com/questions/26676/how-to-check-if-a-shell-is-login-interactive-batch

November 20th, 2012, 03:53 AM
Ah, I had an empty .bash_profile in there. Thanks for the tip, I wouldn't have noticed otherwise.

November 20th, 2012, 03:58 AM
Ah, yeah, that'll do it every time. :)

No problem.

November 20th, 2012, 04:07 AM
Maybe I'll remember next time. 'Best make sure the script will too :)