why is there no name showing at the command line?
Solution 1
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.
Solution 2
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.
Related videos on Youtube
John Smith
Updated on September 18, 2022Comments
-
John Smith over 1 year
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. $
-
Panther over 10 yearsTake a look at the bash config files, including .bashrc. How are you logging in ? via ssh ?
-
Admin over 10 yearsWhich 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
?
-