When I log in as root and enter some random non-existing command, it says:

root@localhost:~# asdf
-bash: asdf: command not found

But when I do the same thing as user rakinar2 it says:

rakinar2@localhost:~$ asdf
bash: asdf: command not found

Now what are difference between -bash and bash?

1 Answer 1


Bash started with a dash - as the first character for the command name (argument #0) starts as a login shell. (So does a shell given the -l / --login switch.) That affects the startup files it reads.

See: 6.1 Invoking Bash and 6.2 Bash Startup Files in the manual.

  • @ArRakin, if a login or non-login shell is started depends on what starts it. I don't know how you logged in as root, but if you're using sudo, sudo -i would start a login shell. Terminal emulators and stuff like screen usually probably start non-login shells, unless you've configured them to start login shells...
    – ilkkachu
    Commented Aug 7, 2021 at 14:51
  • I've used sudo su to log in as root...
    – Ar Rakin
    Commented Aug 7, 2021 at 14:53
  • @ArRakin See also unix.stackexchange.com/questions/218169
    – Kusalananda
    Commented Aug 7, 2021 at 16:09

You must log in to answer this question.

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