Wednesday, March 25, 2009

Changing default shell in ubuntu

I faced this problem when I created a new account using command line where the default shell of my new account is /bin/sh. After googling around, I found 2 useful solutions which are listed below:

1. Change user entry in /etc/passwd
a) edit /etc/passwd using any editor

  • $ vi /etc/passwd
b) find the line that belongs to the user (foo) that we about to modify
  • foo:x:1001:1001::/home/foo:/bin/sh
c) change from /bin/sh to /bin/bash
  • foo:x:1001:1001::/home/foo:/bin/bash
d) save
e) Logout and login back

2. Use chsh command
a) type chsh
  • $ chsh
b) You will be asked for password. Enter your password
c) This screen will appear
  • Enter the new value, or press ENTER for the default
    Login Shell [/bin/sh]:
d) Put /bin/bash at the menu and press Enter

Done :)

3 comments:

chfl4gs_ said...

You should use vipw instead of just vi the passwd file.

backhand said...

how about using the options from useradd command

# useradd foo -s /bin/bash

the user foo will be created with the /bin/bash shell allocated to him.. thanks..

Mitch said...

You can change it permanently with the -D option.

# To see current settings
# useradd -D

# To change default shell for all new accounts
# useradd -D -s /bin/bash

Cheers,
Mitch Sheean