Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I create a normal user account in ubuntu using "useradd" command, but the problem is that I have to type "bash" to launch the bash shell for this user account in both the console mode (in a tty, through ctrl+alt+Fn) and the remote mode (via ssh). The most important part of bash shell for me is the auto-completion function, so my question is that how I could make the bash shell launch automatically when logging into the account.

I use ubuntu 13.04 32bit version. I appreciate for any advice!

share|improve this question
    
    
I think the below proposed approaches can answer your question. –  mikegao88 Apr 15 at 8:27

2 Answers 2

up vote 6 down vote accepted

First of all, check if useradd shows a default value for SHELL. To do that, issue:

useradd -D

This will output something like:

GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/sh
SKEL=/etc/skel
CREATE_MAIL_SPOOL=no

These values are taken from /etc/default/useradd. Now, you have 2 solutions:

  1. Edit /etc/default/useradd, and change the value of SHELL, or
  2. Override the shell's value when adding user with: useradd -D -s /bin/bash

For more information see man useradd.

share|improve this answer
1  
All true and all useful, +1, but it won't help the OP. This will only affect the next user created, not the one that already exists. –  terdon Apr 14 at 13:43
    
Works fine for me, thanks! –  mikegao88 Apr 14 at 18:59
    
Another question, as now I create a user account without home directory, its home directory defaults to the root "/", so how could I still configure the bash profile for this account? I mean for the user account with home directory, its bash profile is in the local directory (bashrc, etc.), but I do not find such file when logging in with the account I created. Thanks! –  mikegao88 Apr 14 at 19:05
    
Will it work, if I just copy the bashrc file to the root directory from other account? –  mikegao88 Apr 14 at 19:10

You probably need to set bash as your new users's login shell. If you are logged in as that user:

chsh -s /bin/bash

To change it for another user

sudo chsh -s /bin/bash username

In future you might want to use adduser instead of the low-level useradd, since it defaults to setting bash as the new login shell.

You can check the login shell (among other details) by looking at the /etc/passwd file or using

getent passwd username
share|improve this answer
    
Good approach, +1 from me! –  Frantique Apr 14 at 12:13
    
I think this is also very useful, thanks for answering! –  mikegao88 Apr 14 at 19:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.