5

On my company's Ubuntu 15.10 desktop system, I log in via Active Directory using some magic based upon PBIS. Thus, my user account is not listed in /etc/passwd even though I have a home directory under /home/local/FOOBAR/dotancohen/. How can I configure bash as the shell when there is no /etc/passwd line to edit and so cannot use chsh?

I do have another account on this machine with admin access, so I can configure the system as admin if needed. However, if there is a user-only solution I would prefer that for use in the future when I won't have admin access!

Here are the results of a few key commands, run from opening Gnome Terminal in Unity (the Ubuntu desktop):

$ echo $HOME
/home/local/TECHMARKETING/dotan
$ whoami
FOOBAR\dotancohen
$ grep dotan /etc/passwd
$ grep sourced ~/.profile
echo 'sourced .profile'
$ grep sourced ~/.bashrc
echo "sourced .bashrc"
$ echo $SHELL
/bin/sh
$ echo $TERM
xterm
$ bash
sourced .bashrc
 - dotan-tm():~$ echo $SHELL
/bin/sh
 - dotan-tm():~$ echo $TERM
xterm-256color

As can be seen, both .bashrc and .profile echo when they have been sourced. It seems that .profile is not run when the default shell starts, but .bashrc is run when bash starts. I used this answer to open bash from dash, but since .profile is not run obviously that script is not having any effect.

Here is my complete ~/.profile file for reference:

$ cat .profile
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
    . "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.bin" ] ; then
    PATH="$HOME/.bin:$PATH"
fi

xmodmap ~/.Xmodmap

export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

case $- in
  *i*)
    # Interactive session. Try switching to bash.
    if [ -z "$BASH" ]; then # do nothing if running under bash already
      bash=$(command -v bash)
      if [ -x "$bash" ]; then
        export SHELL="$bash"
        exec "$bash" -l
      fi
    fi
esac

echo 'sourced .profile'
$ 
  • How exactly are you logging in? Do you have a display manager? Your ~/.pfofile is probably being read, you just don't see the line echoed. Try adding date > /tmp/foo o the end of ~/.profile, does that create /tmp/foo with the current date? If so, there's a simple solution. – terdon Jan 7 '16 at 13:13
6

Using PBIS you can define the default shell for all users:

#/opt/pbis/bin/config LoginShellTemplate /bin/bash

This as to be done as root, there is no possibility to change this setting by user or as an unprivileged user. This will be the default shell for all AD users.

  • Thank you LilloX! In fact, this did resolve my issue in the specific case of being stuck due to PBIS. I would prefer an answer in the general sense, but if none comes along that I will accept this as the answer. Thank you! – dotancohen Jan 7 '16 at 12:50
  • According to download1.beyondtrust.com/Technical-Support/Downloads/files/…, searching for "Set the Login Shell for a Single User" (1/2) – Jeff Schaller Jan 7 '16 at 15:44
  • On your administrator workstation, start Active Directory Users and Computers. In the console tree, expand Users. Right-click the user that you want, click Properties, and then click the PBIS Settings tab. In the list under PowerBroker Cells, click the cell for which you want to set the user's home directory. In the Login Shell box, type the login shell that you want to set—for example, /bin/bash. (2/2) – Jeff Schaller Jan 7 '16 at 15:44
  • @JeffSchaller What software is this? Active Directory Users and Computers on actual Windows Server has no PBIS Settings tab, and the Ubuntu box doesn't seem to have an Active Directory Users and Computers program that I can find logged in as local admin. – Kevin Nov 24 '16 at 15:42
  • Looks like powerbroker, @Kevin – Jeff Schaller Nov 24 '16 at 16:09

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.