Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've created a new Ubuntu Server virtual server. When I SSH in as root, I see:

root@server:

I created a user. When I SSH in as the new user, I see:

$

When I press the up arrow key as root, I see the last command I entered. When I press the up arrow key as the new user, I see:

$^[[A

Delete works as expected as root. As the new user, the delete key inserts:

^[[3~

LS provides color coded results for root, and no color for the new user. Other little vexations exist as well.

I assume there's a configuration file somewhere for root that's set all of these things. How can I apply these UI niceties to the new user I've created as well?

share|improve this question
    
It sounds like you used some unusual tool for user account creation that did essentially no setup. The standard tool on Debian-derived systems is adduser, which should give you a fully-configured account and populated home directory. –  Novelocrat Dec 22 '11 at 21:21
    
Last I checked, Ubuntu doesn't link 'sh' to Bash anymore, they're using Dash. –  Magellan Dec 22 '11 at 21:37

3 Answers 3

Your new user does not have the same shell as your root user.

As root, open up /etc/passwd

Find your root user line. It will be near the top and look like this:

root:x:0:0:root:/root:/bin/bash

The /bin/bash part is important.

Now find your new user. They likely have /bin/sh in the same place that root has /bin/bash.

Replace /bin/sh with /bin/bash and then log in again as your new user. That should solve it.

To make the default shell /bin/bash permanently for all user users, do this as root:

useradd -D -s /bin/bash

You can verify this has been set bytyping useradd -D and observing the value of the SHELL= line.

share|improve this answer
4  
If you are editing the /etc/passwd or /etc/shadow files, use vipw to do so. It does a syntax and consistency check before saving the file to help prevent you locking yourself out. You can also change a user's shell with usermod -s /path/to/new/shell username –  Ladadadada Dec 22 '11 at 20:27
1  
FYI, chsh is the preferred method to change shell. Editing /etc/passwd and /etc/shadow should be discouraged as it can leave an account unable to login if it's not done properly. –  Peter Grace Dec 22 '11 at 21:33

To ensure a similar user experience for everyone you have to perform two steps:

  1. Skeleton/profile files
    • Edit or replace the shell skeleton files (/etc/skel) with the ones you want new users to get
    • Manually copy over the skeleton files for users you've already added. Make sure you chown the files to the user so that they can make changes for themselves!
    • Edit /etc/default/useradd to make sure every new user use the shell you want them to use
  2. Altering the shell used by your current users. There are two methods:
    • The recommended one: chsh -s /path/to/shell username. Cat /etc/shells to see which one your system has
    • The also recommended one: usermod -s /path/to/shell username
    • The absolutely NOT recommended one: vipw. You are editing the user database directly this way. Delete a character on the wrong place and you've locked yourself out. You're warned.

A relevant tip regarding vipw - many people don't know how to use vi. Instead of learning it just for the use of vipw you can export a different editor in the enviroment before launching vipw. Example:

# export EDITOR=nano
# vipw

This will then launch the vipw wrapper via nano

share|improve this answer
    
Also note that you can change your default editor by editing the appropriate shell configuration file (Usually .profile, may be in .bashrc or other locations depending on your shell and how your OS sets up the skeleton files.) –  voretaq7 Dec 22 '11 at 21:45

for useradd you dont want to do it everytime you create a new user you can do"

edit the /etc/default/useradd skeleton file (don't forget to make a backup though).

Edit the SHELL variable to be /bin/bash instead of /bin/sh.

Now every time you use useradd to add a new user bash is automatically their default shell. " If you want to change the shell of already existing users you have to edit the /etc/passwd file (please make sure to back have a backup of it).

share|improve this answer
    
for the color coded results –  harish.venkat Dec 22 '11 at 20:01
    
This does not do anything for new users that are created. They will still get /bin/sh if useradd -D -s /bin/bash is not used. –  jdw Dec 22 '11 at 20:07
    
Unbuntu Server uses /etc/bash.bashrc for those customizations. –  Tim Dec 22 '11 at 20:59
    
i am using arch linux so in my computer it is .bashrc sorry for the mistake –  harish.venkat Dec 22 '11 at 21:00

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.