I am using turnkeylinux LAMP server which is debian based. When I log in, my shell is basically just $ and no colors, no dirname, just very basic. I have to use the bash command which then initializes everything so i have colors, vim is correct, the path is showing in terminal etc.

I have to do this every time I sudo su into another user. Is there a master place i can change to execute the bash command whenever i login or user su?

My login 'typing' is this.

type myusername
type mypassword
type bash <- so when i exit from su, i know i'm really back. Why can't this auto run?
type sudo su developer
type bash <- again so i know where i am. Auto run this command after the su

Its just a small annoyance i cannot seem to figure out.


  • 1
    How about just setting bash as your login shell, then invoking su with the -m, -p, --preserve-environment option? – steeldriver Aug 12 '16 at 14:49

Your login shell is likely /bin/sh, check with getent passwd username. (Last field on the line.) You can change it with chsh, either without arguments so it'll ask what you want, or with something like chsh -u user /bin/bash. Same for the other account. chsh will ask for your password unless you're root.

sudo su is redundant, since both sudo and su are meant for elevating privileges. Consider just sudo -s or sudo -i (depending on if you want a login shell or not, it'll affect which startup files are read).

If you want to run something else when starting a session /etc/profile and ~/.bash_profile should work for login shells (i.e. when logging in with SSH or with sudo -i). (Gory details here)

  • That was it. My shell was /bin/sh not /bin/bash. I used chsh -s /bin/bash on my environment, but it now uses the correct shell. Thanks. – CarComp Aug 15 '16 at 14:24

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.