Find the answer to your Linux question:
Results 1 to 3 of 3
It seems to me that every command that one can run is run from the shell (most commonly bash). But...where is bash started from? How does it start? Is there ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jul 2005
    Location
    look out your window
    Posts
    72

    An odd question came to me...how does bash start?


    It seems to me that every command that one can run is run from the shell (most commonly bash).
    But...where is bash started from? How does it start? Is there a way to run commands without a command prompt?
    this question just came to me one day while talking to my friend about linux, i was trying to get him to look into it
    any answers/links would be helpful

  2. #2
    Linux User
    Join Date
    Aug 2005
    Location
    Italy
    Posts
    401
    Well... A process (a program) is started from another program. ALWAYS.

    The first process started is init (from Linux kernel at startup). Then, init launch many processes (it's behavior is determined by the inittab file). For non graphical workstations, init start getty process, wich will start login process. Once you got the access, login will start the default shell (often bash)... then bash will start any program thru its prompt... that's it.

    For graphcal workstation, the desktop enviroment start a terminal emulator (xterm, konsole, gnome-terminal), wich will start bash, wich you can use to start programs.

    ... a program can started without bash? Yes. For example, graphical applications are started without any shell (however they are started by the graphical shell, like KDE or Gnome or XFCE...).
    When using Windows, have you ever told "Ehi... do your business?"
    Linux user #396597 (http://counter.li.org)

  3. #3
    Linux User Krendoshazin's Avatar
    Join Date
    Feb 2005
    Location
    London, England
    Posts
    471
    If you take a look at the process tree with the command pstree, you'll see the process structure of the system. Init is the master process which gets pulled into play when then kernel is booting, and then all the system processes are run directly off init.
    Each virtual terminal (tty) gets login (edit: actually it gets agetty run on it, or does in my case through the tty's defined in /etc/inittab, and -then- login) run on it, or in some cases you can run other things, but there's no need to go into that right now.

    Login is part of the shadow package, which is usually linked against the pam authentication layer, once you've successfully logged in, bash (or your choice of shell) is then called by login and run with login as the parent process of bash. You can see that here

    Code:
    |-login---zsh---splitvt-+-zsh---madplay
    |                       `-zsh---irssi
    |-2*[login---zsh---vi]
    |-login---zsh
    It's the same principle for graphical login, except that gets pulled up, e.g gdm, kdm, xdm, in a different runlevel and that handles the login instead, and then X gets executed once you've logged in, as you'll see here

    Code:
    |-login---zsh---startx---xinit-+-X
    |                              `-sh---fluxbox
    fluxbox basically runs on top of X, and interprets the data as it comes in, but that's one for another day.

  4. $spacer_open
    $spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •