Results 1 to 5 of 5

Thread: .bashrc/aliases not loading per SSH session

  1. #1
    Join Date
    Aug 2012
    Beans
    31

    .bashrc/aliases not loading per SSH session

    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.
    Last edited by chrisinpants; November 20th, 2012 at 03:22 AM. Reason: update

  2. #2
    Join Date
    Nov 2012
    Beans
    12

    Re: .bashrc/aliases not loading per SSH session

    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
    Code:
    case $- in
      *i*) echo "This shell is interactive";;
      *) echo "This is a script";;
    esac
    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/questi...eractive-batch
    Last edited by aliddell; November 20th, 2012 at 03:42 AM. Reason: make the code a little more readable, credit where it's due.

  3. #3
    Join Date
    Aug 2012
    Beans
    31

    Re: .bashrc/aliases not loading per SSH session

    Ah, I had an empty .bash_profile in there. Thanks for the tip, I wouldn't have noticed otherwise.

  4. #4
    Join Date
    Nov 2012
    Beans
    12

    Re: .bashrc/aliases not loading per SSH session

    Ah, yeah, that'll do it every time.

    No problem.

  5. #5
    Join Date
    Aug 2012
    Beans
    31

    Re: .bashrc/aliases not loading per SSH session

    Maybe I'll remember next time. 'Best make sure the script will too

    Cheers

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •