0

I am trying to find the names/differences/what is the symbol called at the of the prompt provided at the entry line for Bash.

For example: user@user~$ what is the $ called, and why on some systems is user % not $? is that a setting that can be changed?

I am thinking about this from the perception of Cisco IOS, between > (user) to # privileged exec. The symbols serve a purpose there, so what purpose do they serve on a *Nix system?

1
  • Cisco IOS is a *Nix system for that matter :D – Bananguin Sep 7 '16 at 14:12
2

I'm not sure the character has a name; it's traditionally used to indicate whether you're root or not (# means you're root, $ or % means you're not). $ is used in Bourne-style shells (including Bash), % is used in the C shell and Zsh. In Zsh the definition is slightly wider: # is displayed if you're root or if you have raised POSIX capabilities.

Your prompt definition determines whether this appears: in Bash, \$ in a prompt definition is replaced by # or $, in Zsh, %# is replaced by # or %. You can use other characters in Zsh by using the expanded version, %(!.#.%%).

Why is $ the default symbol for a user shell and # the default symbol for a root shell? has more info.

2
  • at least on Debian, tcsh seems to show > for a normal user and # for root, which matches the Cisco convention. – ilkkachu Sep 7 '16 at 14:22
  • @ilkkachu It does that if you start it as tcsh; if you start it as csh it uses % and #. The characters can be customised using the promptchars variable. – Stephen Kitt Sep 7 '16 at 14:26
1

From man bash:

PROMPTING When executing interactively, bash displays the primary prompt PS1 when it is ready to read a command, and the secondary prompt PS2 when it needs more input to complete a command. Bash allows these prompt strings to be customized by inserting a number of backslash-escaped special characters that are decoded as follows:

...

  • \$ if the effective UID is 0, a #, otherwise a $

So, it is hard-coded in the bash*. The same probably applies to other shells. I recall that on very old unices from 80'es it used to be %. Nowadays csh uses %


* You could of course customize the PS1, but without this builtin feature to use one or another char based on UID

Not the answer you're looking for? Browse other questions tagged or ask your own question.