LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   what is mean "-bash" (https://www.linuxquestions.org/questions/linux-newbie-8/what-is-mean-bash-927142/)

freelearn 02-02-2012 07:57 AM

what is mean "-bash"
 
hi
what is meaning dash first of bash in outpu `ps -aef | grep bash` command

brianL 02-02-2012 08:31 AM

It indicates the options given to the command, in that case, ps.
http://linux.die.net/man/1/ps

Mr. Alex 02-02-2012 11:27 AM

Some programs use a style when one dash means a character for an option and two dashes mean one option which is several characters. But some programs take one dash and then an option which can contain several chars. For example:
Code:

feh -FY
means
Code:

feh -F -Y
so there are two options.

But
Code:

find / -iname '*pattern*'
has just one option - "iname" but not "-i -n -a -m -e" even though has one dash before. You just gotta figure it out for each program.

catkin 02-02-2012 11:35 AM

It would be helpful to see the output that includes "-bash"

jthill 02-02-2012 12:20 PM

Bash interprets being invoked with a leading - in its name as the --login option. See the INVOCATION section in the bash manual.

suicidaleggroll 02-02-2012 12:28 PM

Nevermind

freelearn 02-02-2012 12:57 PM

a simple output on my system (with run command 'ps -aef | grep bash')
kumaas 12582 12580 0 14:08 pts/0 00:00:00 bash
kumaas 15784 15776 0 15:59 tty2 00:00:00 -bash
root 25736 25728 0 20:54 pts/0 00:00:00 -bash
root 26922 25736 0 21:20 pts/0 00:00:00 grep bash
in line 2 and 3 bash started with dash but the other two lines do not

jthill 02-02-2012 02:41 PM

When programs are run on unix systems, they are passed a set of strings. Whatever invokes them builds that set. The shell does it, the login process does it, every program is run by calling some variant of the "exec" system call.

The first of those strings is conventionally the string that was used to invoke the program, but the important thing to understand is that that's only a convention. For instance, here's how you run bash and tell it its name is "hahaha funny":
Code:

~/sandbox/49381$ cat >exectest.c
#include <unistd.h>
void main()
{
        execl("/bin/bash","hahaha funny",0);
}
~/sandbox/49381$ make exectest
cc    exectest.c  -o exectest
~/sandbox/49381$ ./exectest
~/sandbox/49381$ echo $0
hahaha funny
~/sandbox/49381$ ps f
  PID TTY      STAT  TIME COMMAND
11697 pts/0    Ss    0:00 bash
31603 pts/0    Sl    2:13  \_ /opt/google/chrome/chrome --disable-gpu-blacklist http://mail.google.com/mail/#inbox
31608 pts/0    S      0:04  |  \_ /opt/google/chrome/chrome --disable-gpu-blacklist http://mail.google.com/mail/#inbox
 3732 pts/0    S      0:00  \_ hahaha funny
 3785 pts/0    R+    0:00      \_ ps f


catkin 02-03-2012 02:02 AM

I vaguely remember that bash processes that show up as -bash in ps output are login shells. Presumably the login binary uses the technique explained by jthill to make it so.

A test has just confirmed that a login shell does indeed show up that way. I had to use a virtual terminal; presumably the bash login process that results from using a graphical login screen hash bash replaced by some other program.

brianL 02-03-2012 05:33 AM

I misunderstood the question. :redface:
Never noticed that -bash output in ps before. I've still a lot to learn, so much to cram into such a tiny, aging brain. :)

catkin 02-03-2012 11:28 AM

Quote:

Originally Posted by brianL (Post 4592696)
I misunderstood the question.

It was not clear until post #7 -- and the brain-size solution is to forget stuff as fast or faster than learning it :D


All times are GMT -5. The time now is 08:31 PM.