What is the difference between bash and -bash. When I execute echo $0, it returns bash on one machine and -bash on the other machine. What is the difference between them?

  • 1
    I think it's only a matter of formatting the output. As far as I know, there's no such thing as a -bash shell, but I could be mistaken of course. May 22, 2013 at 8:30
  • 1
    $0 is only the name of the command by convention. And another convention is for a login shell to have - in front of its name in $0. If you look at man exec you'll see that you can make $0 be anything you like when you execute bash. May 22, 2013 at 8:34

1 Answer 1


Processes with a - at the beginning of arg 0 have been run via login, or by exec -l in bash.

  • Thanks :) After reading your answer, I did help exec and that reads, If the first argument is '-l', then place a dash in the zeroth arg passed to FILE, as login does. May 22, 2013 at 8:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .