2

My problem: My web host offers ssh to their shared server. I want to set up a couple of aliases and such, so I'm trying to get a login script of any flavor to run. If my shell was plain bash, I would simply add my stuff to one of the dotfiles and be done with it.

Now, as it happens, my shell is specified as /bin/sh, which is linked to bash:

sh-3.2$ /bin/sh --version
GNU bash, version 3.2.25(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.
sh-3.2$ /bin/bash --version
GNU bash, version 3.2.25(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.
sh-3.2$

I've tried creating all the usual suspects, ~/.bash_profile, ~/.bash_login, ~/.bashrc, ~/.profile and .login without luck.

What can I do to execute a command on startup? Any file names I've forgotten to try? Should any of these work under my conditions? I.e. has my host done something to disable login script?

I'd prefer not asking my host to set a different shell for me until I've gotten my facts straight about this.

1
  • 1
    Bash, like all other shells you might find as /bin/sh, executes commands from ~/.profile when you log in, unless you have a shell-specific file such as ~/.bash_profile. What does ps $$ $PPID show at this shell prompt? What about ls -ld ~/.*profile and echo $-? What happens if you remove (or rename) all of the .bash* files, and put set -x at the top of ~/.profile? Nov 26, 2011 at 15:41

2 Answers 2

3

From the Bash manual section 6.2 Bash Startup Files:

Invoked with name sh

If Bash is invoked with the name sh, it tries to mimic the startup behavior of historical versions of sh as closely as possible, while conforming to the posix standard as well.

When invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first attempts to read and execute commands from /etc/profile and ~/.profile, in that order. The --noprofile option may be used to inhibit this behavior. When invoked as an interactive shell with the name sh, Bash looks for the variable ENV, expands its value if it is defined, and uses the expanded value as the name of a file to read and execute. Since a shell invoked as sh does not attempt to read and execute commands from any other startup files, the --rcfile option has no effect. A non-interactive shell invoked with the name sh does not attempt to read any other startup files.

0

You can run chsh to change your shell to /bin/bash.

chsh -s /bin/bash

bash invoked as /bin/sh should execute your ~/.profile at logon.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .