8

a hopefully simple one here, I don't know why there's no username at the $ when a new account is added and you login?

 Welcome to Ubuntu 12.04.3 LTS (GNU/Linux 3.2.0-23-generic-pae i686)

 * Documentation:  https://help.ubuntu.com/

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

You have mail.
$
John Smith
  • 85
  • 1
  • 1
  • 3
  • Take a look at the bash config files, including .bashrc. How are you logging in ? via ssh ? – Panther Dec 09 '13 at 21:02
  • Which shell is used here? How do you login as the user? From a TTY or maybe through su user? What's the output of [ -f ~/.bashrc ] && cat ~/.bashrc || echo no .bashrc? –  Dec 09 '13 at 21:47

3 Answers3

9

If you added the new account using useradd then it likely set the new user's login shell to be /bin/sh, which in Ubuntu is a symbolic link to the dash shell. Dash is a simpler shell which doesn't read the ~/.bashrc file and doesn't set the user@host command line prompt. You can check by looking in the /etc/passwd file, or using

getent passwd username

and you can change the default shell to the more usual bash using

chsh -s /bin/bash

if you are logged in as the user whose shell you want to change, or

sudo chsh -s /bin/bash username

to change another account's login shell. To prevent this happening again, you can either specify the login shell on the useradd command line using the -s or --shell options, or use the higher-level utility adduser instead.

steeldriver
  • 136,215
  • 21
  • 243
  • 336
1

The basic Bash prompt is just a variable named PS1. This variable is usually set up in the ~/.bashrc file. The bash shell reads that file when it starts and sets up the variable. If the PS1 variable is not set up in the .bashrc (or .profile) file, then it you will have no prompt. In your case the PS1 variable is set to $:

export PS1="\$"

You can experiment with the variable, e.g try:

  • export PS1="\u\$"
  • export PS1="\u@\h\$"

You will see how the prompt changes. Edit your bashrc file the way you want your prompt to be shown. For more info go here.

falconer
  • 15,026
  • 3
  • 48
  • 68
0

as seen in another question, which solved it for me https://askubuntu.com/a/1064774/212948

As shown on this Ubuntu wiki page, you should run

sudo dpkg-reconfigure dash

and select the option not to use /bin/dash as the default shell. Making the change this way will not only fix the symlink /bin/sh, but will also configure other parts of your system to behave correctly, such as making sure that man sh points to the bash manpage instead of the dash one.