LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-02-2012, 07:57 AM   #1
freelearn
LQ Newbie
 
Registered: Jan 2012
Posts: 3

Rep: Reputation: Disabled
what is mean "-bash"


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

Last edited by freelearn; 02-02-2012 at 08:08 AM.
 
Old 02-02-2012, 08:31 AM   #2
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware & Slackware64 14.1
Posts: 7,453
Blog Entries: 55

Rep: Reputation: Disabled
It indicates the options given to the command, in that case, ps.
http://linux.die.net/man/1/ps
 
Old 02-02-2012, 11:27 AM   #3
Mr. Alex
Senior Member
 
Registered: May 2010
Distribution: No more Linux. Done with it.
Posts: 1,238

Rep: Reputation: Disabled
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.
 
Old 02-02-2012, 11:35 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
It would be helpful to see the output that includes "-bash"
 
Old 02-02-2012, 12:20 PM   #5
jthill
Member
 
Registered: Mar 2010
Distribution: Arch
Posts: 211

Rep: Reputation: 67
Bash interprets being invoked with a leading - in its name as the --login option. See the INVOCATION section in the bash manual.
 
Old 02-02-2012, 12:28 PM   #6
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,258

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
Nevermind
 
Old 02-02-2012, 12:57 PM   #7
freelearn
LQ Newbie
 
Registered: Jan 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
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

Last edited by freelearn; 02-02-2012 at 12:59 PM.
 
Old 02-02-2012, 02:41 PM   #8
jthill
Member
 
Registered: Mar 2010
Distribution: Arch
Posts: 211

Rep: Reputation: 67
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
 
1 members found this post helpful.
Old 02-03-2012, 02:02 AM   #9
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
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.

Last edited by catkin; 02-03-2012 at 02:03 AM. Reason: missing words
 
Old 02-03-2012, 05:33 AM   #10
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware & Slackware64 14.1
Posts: 7,453
Blog Entries: 55

Rep: Reputation: Disabled
I misunderstood the question.
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.
 
Old 02-03-2012, 11:28 AM   #11
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Quote:
Originally Posted by brianL View Post
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script: using "select" to show multi-word options? (like "option 1"/"o zidane_tribal Programming 7 12-19-2015 02:03 AM
BASH:find out if volume "foo"/folder "goo" can be written to SilversleevesX Programming 2 08-28-2010 11:03 AM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 11:18 PM
C/C++ functions similar to BASH's "cp", "mv", "mkdir", etc? kornerr Programming 10 04-23-2006 10:48 AM
bash-2.05b# Xlib: extension "XFree86-DRI" missing on display ":0.0". citrus Linux - General 8 02-22-2004 11:43 AM


All times are GMT -5. The time now is 12:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration