Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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
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
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 01:03 AM.
Reason: missing words
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.