tags:

views:

367

answers:

8

I often getting confused with bash and shell. Are they same? If I want to learn the bash, will it be covered with Linux shell programming related books? I use Ubuntu Linux.

Edit: (Added after getting two answers.) How bash is associated with terminal?

+3  A: 

"bash" is one of many available "shells" for Linux i.e. "bash" typeof "shell" == true

jldupont
does this means that when I open terminal from ubuntu desktop, it runs on bash? how it is associated with terminal?
Gopalakrishnan Subramani
The "terminal" on Ubuntu Linux presents a window on a "dash" (a shell... or is it "bash", I am not sure now) process, yes.
jldupont
what awful pseudo language is this?
Matt Joiner
+2  A: 

No. bash is one shell. Technically Linux is not a shell but in fact the kernel, but many different shells can run on top of it (bash, tcsh, pdksh, etc.). bash just happens to be the most common one.

Ignacio Vazquez-Abrams
Is ssh server expose the bash shell by default? (I don't spend more time on linux and mostly I do midnight hacking) sorry for so many questions.
Gopalakrishnan Subramani
The ssh server uses the preferred login shell (see the `chsh(1)` man page) of the user logging in.
Ignacio Vazquez-Abrams
nice. good information.
Gopalakrishnan Subramani
+10  A: 

bash is one particular type of Linux shell (the Bourne again shell), but there are quite a few others. In Ubuntu, bash is the default. I am sure that there are numerous shell programming books that cover it, I've read one in the past.

Kaleb Brasee
Actually, dash is the default Ubuntu shell.
Ignacio Vazquez-Abrams
Dash is the default `/bin/sh` but the default login shell is still Bash.
ephemient
Okay, fair enough.
Ignacio Vazquez-Abrams
+1  A: 

Try: http://en.wikipedia.org/wiki/Unix_shell Hint: Bash is a type of Unix shell.

Sudhanshu
+3  A: 

Taken from linuxcommand.gds.tuwien.ac.at:

Simply put, the shell is a program that takes your commands from the keyboard and gives them to the operating system to perform. In the old days, it was the only user interface available on a Unix computer. Nowadays, we have graphical user interfaces (GUIs) in addition to command line interfaces (CLIs) such as the shell.

On most Linux systems a program called bash (which stands for Bourne Again SHell, an enhanced version of the original Bourne shell program, sh, written by Steve Bourne) acts as the shell program. There are several additional shell programs available on a typical Linux system. These include: ksh, tcsh and zsh.

Dor
+2  A: 

No, they are not the same, and yes, linux shell programming books should have significant portions or be entirely about bash scripting.

Ubuntu is a distribution of linux which contains bash as an available shell. When you open a terminal in Ubuntu, you're opening a screen that emulates a display with a certain number of rows and columns. Bash is a program that can run on a terminal and allow you to interact with the system. It is much like the dos prompt in a command window in windows, if you are familiar with that.

You can have multiple shells, but many people prefer bash and you'll have the best luck learning it first.

Good luck!

jsoverson
+1  A: 

In order to have certain scripts be portable between AIX and Linux I have had to do have specific logic to determine the box type and run variations of certain commands.

For exmaple:

If you were using a '\c' to prevent a newline at the end of an echo, you'll have to change to "echo -n".

Also, the ping syntax changes a little.

I would think the majority of commands would be approx the same with some slight nuance changes every now and again.

Courtland
ping syntax has nothing to do with the shell. In fact very little of this answer has much to do with the OP's question.
Dennis Williamson
Honest mistake... misread the question.
Courtland
+5  A: 

This question is getting a little stale, but I thought I might clear up the distinction between terminal and shell as requested in the second part of the question. You can think of the terminal as a display device. These days, it is most typically a program, but there was a time when the terminal was a separate box. When you start the terminal program, it will send a wakeup signal to the local system. In the old days, the physical terminal sent a electrical signal on the (typically RS232) connection to the terminal interface. In either case, the operating system sends a "login" text back to whatever device or program sent the wakeup signal. The shell is not involved yet.

The operating system completes the login by verifying the user name and password (if any). Then it checks the verified user's entry in the password file for the name of that user's preferred shell. There is a default shell assigned when the account is created, and the user can generally change that assignment later. The OS starts the shell program, and the shell inherits the communications path connected to the terminal. The terminal program is still there, displaying the text sent to it and sending what the user types back up the communications line. Now it is the shell on the other end of the line, not the OS.

Any program can be assigned as the users initail login shell. It would be possible, but not very useful, to assign the 'date' program as the login shell. In that case, after login the user would just see the date displayed in his terminal window, and would be logged off. The difference between the terminal and the shell is that the terminal is always there, listening and talking with the user. It does not interpret the keystrokes (beyond mapping to a character set). The shell is what the OS starts up (or the user later adds in stack-like fashion) to handle communications on the other end of the terminal communications line. It decides on an action to take in response to a user's keystrokes.

gary