On one of my servers, the prompt is [user@host path]...and I can actually push "tab" to auto-fill the path.
But on my new Ubuntu server, it is just a dollar sign?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.
Sign up to join this communitySince you are asking two questions, I'll answer both.
Because you shell either doesn't support it, or tab completion isn't turned on.
To resolve this, you first need to discover what your shell is. On the machine whose shell you enjoy, run
echo $SHELL
You may see the common /bin/bash
, or something less common like /bin/tcsh
, /bin/zsh
or something else entirely.
Now, you can change your shell on Ubuntu machine. On that machine, first make sure that the shell you want exists. Since the shell might not be in the same location on the Ubuntu machine as on the other, check the location by typing
which bash
This will give you the path of the shell you want, something like /bin/bash
, /usr/bin/bash
, or /usr/local/bin/bash
. Of course, if you want a shell other than bash, you'll say which tcsh
, which zsh
, or similar.
If you don't see a path, but instead see bash not found
, then you'll need to install the appropriate package, and again use which
to find out where the shell was installed.
With the path of your chosen shell, you can finally change your shell by running
chsh -s /bin/bash
replacing /bin/bash
with whatever the appropriate path for your shell of choice is.
Because of your prompt environment variables $PS1
, $PS2
, and so on. These things don't tend to be portable between shells, so here's a few links for likely candidates:
bash
has an extensive manual, with pages on Bash Variables (including PS1
, &c) and Printing a Prompt (which describes PROMPT_COMMAND
, the long name for PS1
). Add the following line to your ~/.bashrc
export PS1='[\u@\h \w] '
tcsh
has an online manual (just its man page), with a section on the prompt environment variables. Add the following line to your ~/.tcshrc
set prompt='[%n@%m %~] '
zsh
has a user guide, with a simple guide to prompts, as well as a manual, with a very detailed reference on Prompt Expansion. Add the following line to your ~/.zshrc
export PS1='[%n@%m %~] '
i guess, you are not using bash, but sh and your prompt is not set properly (if this is even possible with sh).
you can get your current shell by typing: echo $SHELL
if you want to start bash, just type bash
sh
. Echoing $SHELL
will print an environment variable called SHELL
. This environment variable simply points to the shell, and is only set by bash. It is approximately useless in determining which shell is running, as it only indicates, weakly, that some parent of the current process may have been bash.
Nov 10, 2009 at 9:52
/bin/sh
, yes. But I know of no shell whose name is sh
. I can think of ash
, ksh
, csh
, bash
, zsh
, and tcsh
. The first one is the usual /bin/sh on linux and NetBSD, the last is the usual FreeBSD shell, and the others are optional shells. Many desktop environments change the users login shell to bash while leaving /bin/sh as ash.
Nov 10, 2009 at 10:01
sh
is the Bourne shell. en.wikipedia.org/wiki/Bourne_shell Some systems (Solaris) still come with a version of Bourne shell that is not just a copy of one of the re-implementations (ash, dash, bash, ksh, zsh).
Nov 10, 2009 at 10:23
Bash is not the only shell.
Your issue could be a simple matter of not having a .profile or .bashrc that sets PS1, or it could be that your login shell is not bash at all.
Bash uses gnu readline
for things like tab completion. This is a complicated subject and readline even has its own per-user config file.
See man bash
, man sh
, and man 3 readline
. Bash responds to --version
. On many linux systems, /bin/sh
is not actually bash, but usually a crippled version of ash
.
You need to set a variable called PS1 on one of your login script, for example /etc/profile or ~/.bashrc. It will depend on your distribution.
Example: http://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html
pwd
to print the name of the current working directory. And are you saying that Tab-completion is not working either? (On some machines I use, I get that short prompt only if I login as root, and I happily leave that in place as a nice warning. As one seldom, if ever, needs to login as root: you're not using root, are you?)