In htop, or other commands that show process status, all bash processes have in the command column
/bin/bash
but one process has in the command column
-bash
What does it mean?
processshell
In htop, or other commands that show process status, all bash processes have in the command column
/bin/bash
but one process has in the command column
-bash
What does it mean?
Best Answer
A minus sign before the command name is a convention that login programs use to start login shells. A login program is a program where you typically type your password and that starts a session for you, such as
login
,sudo -i
,su -
, sshd, etc. A login shell is the initial shell of a text mode session.Conventionally, when a program invokes another program, it passes the program's name as argument 0; command line arguments are numbered starting from 1. For example, when you run
cp foo bar
, this executes the executable file located at/bin/cp
(on typical systems), and passescp
as argument 0,foo
as argument 1 andbar
as argument 2. The normal convention is to use the base name of the executable as argument 0. When a login program invokes a shell, it violates this convention and puts an extra hyphen before the program name. Shells understand this alternate convention and set things up appropriately for a login shell, typically reading an initialization file such as~/.profile
,~/.login
,~/.bash_profile
, etc. depending on the shell.See also Difference between Login Shell and Non-Login Shell?