2

What do the symbols mean # and $. Why # for root?

Where do these conventions come from?

damadam
  • 2,815
  • 3
  • 17
  • 38
Benzle
  • 882
  • 1
  • 7
  • 15
  • @GeorgeUdosen the answer doesn't address where doss the convention come from. – schrodingerscatcuriosity Nov 28 '19 at 00:28
  • Tradition; It was that way when I learnt it early 80s when we were told it was a convention & they had no special meaning other than $=work (money; where you earn your living), #=danger (it could go bad and you'll see the # as appeared then on batman tv shows instead of violence) – guiverc Nov 28 '19 at 00:34

1 Answers1

5

Tradition; It was that way when I learnt it early 80s when we were told it was a convention & they had no special meaning other than $=work (money; where you will earn your living), #=danger (it could go bad and you'll see the "#"'s as appeared then on batman tv shows instead of hits or violence)

The problem is they can easily be changed, and are shell specific. I learnt what I said before at univeristy where we used bourne SHell; the modern BASH having replaced original bourne SHell so it follows its traditions.

If you use other shells those "$" and "#" could be replaced by other characters (eg. "%" depending on shell chosen).

Further as stated they can be replaced via $PS1 (prompt) so should not be relied on to mean anything anyway.

They are at best an indication of what shell you may be using, and what level of environment (user or root) you may be in - but it's far safer to assume nothing.

guiverc
  • 28,623
  • 5
  • 46
  • 74
  • Thank you so much! I had trouble googling that question for some reason. – Benzle Nov 29 '19 at 05:50
  • 1
    The correct answer is that `#` is the comment character. All the dangerous commands that you're typing as root look like they are commented out if you plonk them into a shell script, or accidentally copy them and paste them back into the terminal. If you quote your session in an e-mail, like to give someone some admin commands, they can't just blindly paste the whole swath of them into their shell. – Kaz Nov 29 '19 at 23:29
  • 1
    In the bash `PS1` prompt syntax, there is a `\$` code which produces `#` and `$` depending on the privileges of the user. I don't think these can be customized; the only way would be to plonk a literal character there instead of `\$`. – Kaz Nov 29 '19 at 23:32
  • I don't like my chances of finding my university lecturer & setting him straight, nor the students I probably repeated it to in tutorial (as a tutor) - though copy/paste wasn't very common on dumb terminal/tapes/cards still then in use in that era (unlike today so I suspect that's a more modern reason). We didn't have mice, and `vi` was great as most terms still didn't have arrow keys. – guiverc Nov 30 '19 at 00:41