1

I am trying to source my .bashrc file on remote host inside sudo-less user. I am getting following responses.

sh-4.2$ source .bash_profile sh-4.2$ source: .bash_profile: file not found sh-4.2$ source ~/.bash_profile [user@hera ~]$ 

Why is this behavior?

added image

contents of .bash_profile

contents of .bashrc

# .bashrc # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi # Uncomment the following line if you don't like systemctl's auto-paging feature: # export SYSTEMD_PAGER= # User specific aliases and functions # added by Anaconda3 4.1.1 installer export PATH="/home/tensorflow/anaconda3/bin:$PATH" 
9
  • Something funny going on, you're supposed to see bash: .bashrc: No such file or directory if .bashrc cannot be found. Commented Sep 16, 2016 at 20:28
  • Why does your command prompt look like that and what shell are you using? What OS? Why didn't your .bashrc load when you logged in? Commented Sep 16, 2016 at 20:35
  • I know .bash_profile, not .bashrc Commented Sep 16, 2016 at 21:29
  • @RyanBabchishin, added the image for clearing your doubts Commented Sep 16, 2016 at 22:12
  • I'm just wondering about the funny error message. You should be getting the one I showed you. Can you verify what your default shell is? grep dd2 /etc/passwd will tell you. Can you post the contents of .bash_profile? And the output of help source? Commented Sep 16, 2016 at 22:40

2 Answers 2

5

You are using bash in POSIX mode.

From man bash under source filename [arguments]

If filename does not contain a slash, file names in PATH are used to find the directory containing filename... When bash is not in posix mode, the current directory is searched if no file is found in PATH.

Bash is running in posix mode because you have started it as sh rather than bash (thus the command prompt being sh-4.2). You will need to change your shell to /bin/bash in order to use "bash-isms" like this.

1
  • Bingo! Nice one... never seen that before. Commented Sep 16, 2016 at 22:42
0

you can see what is the path with pwd command - i bet that your .bashrc is not in the current working directory

3
  • no, pwd is right. Even tab-auto-complete is completing it. Commented Sep 16, 2016 at 20:04
  • both my .bashrc and .bash_profile are in home/user directory. Commented Sep 16, 2016 at 20:11
  • ~/.bash_profile expands to /home/user/.bash_profile , so that is why it is working. when you login via ssh it seems that it cannot find it, so i've assumed user sits in the wrong directory. (assuming things - shame on me). hope you will get better answer :) Commented Sep 16, 2016 at 20:16

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.