开发者

Are Bash and Linux shell the same?

I often getting con开发者_JAVA百科fused 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?


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.


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.


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.


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


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.


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!


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜