Lts0010:修订间差异

来自Ubuntu中文
跳到导航跳到搜索
Wanglijuncode留言 | 贡献
无编辑摘要
Wanglijuncode留言 | 贡献
无编辑摘要
第1行: 第1行:
== What is "the shell"?  ==
== 什么是Shell?  ==


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.  
简单的说, shell就是一个小程序,这个小程序可以接受来自键盘的命令并把这些命令发送到操作系统,再有系统来执行。在过去,在安装有Unix的计算机上,这是唯一的可用的交互式操作。而如今,我们可以通过图形化界面来输入命令行,比如shell.  


On most Linux systems a program called <code><nowiki>bash</nowiki></code> (which stands for Bourne Again SHell, an enhanced version of the original Bourne shell program, <code><nowiki>sh</nowiki></code>, written by Steve Bourne) acts as the shell program. There are several additional shell programs available on a typical Linux system. These include: <code><nowiki>ksh</nowiki></code>, <code><nowiki>tcsh</nowiki></code> and <code><nowiki>zsh</nowiki></code>.
在大多数的linux计算机中,安装有个一个叫bash(bash是Bourne Again SHell的简写,这是有Steve Bourne编写的一个早期shell的升级版。),它充当shell的角色。通常在Linux计算机上有多种可用的shell,比如:ksh、tcsh、 zsh。


== What's an xterm, gnome-terminal, konsole, etc.? ==
== What's an xterm, gnome-terminal, konsole, etc.? ==

2008年6月26日 (四) 23:59的版本

什么是Shell?

简单的说, shell就是一个小程序,这个小程序可以接受来自键盘的命令并把这些命令发送到操作系统,再有系统来执行。在过去,在安装有Unix的计算机上,这是唯一的可用的交互式操作。而如今,我们可以通过图形化界面来输入命令行,比如shell.

在大多数的linux计算机中,安装有个一个叫bash(bash是Bourne Again SHell的简写,这是有Steve Bourne编写的一个早期shell的升级版。),它充当shell的角色。通常在Linux计算机上有多种可用的shell,比如:ksh、tcsh、 zsh。

What's an xterm, gnome-terminal, konsole, etc.?

These are called "terminal emulators." They are programs that put a window up and let you interact with the shell. There are a bunch of different terminal emulators you can use. Most Linux distributions supply several, such as: xterm, rxvt, konsole, kvt, gnome-terminal, nxterm, and eterm.

Starting a Terminal

Your window manager probably has a way to launch programs from a menu. Look through the list of programs to see if anything looks like a terminal emulator program. In KDE, you can find "konsole" and "terminal" on the Utilities menu. In Gnome, you can find "color xterm," "regular xterm," and "gnome-terminal" on the Utilities menu. You can start up as many of these as you want and play with them. While there are a number of different terminal emulators, they all do the same thing. They give you access to a shell session. You will probably develop a preference for one, based on the different bells and whistles each one provides.

Testing the Keyboard

Ok, let's try some typing. Bring up a terminal window. You should see a shell prompt that contains your user name and the name of the machine followed by a dollar sign. Something like this:

[me@linuxbox me]$

Excellent! Now type some nonsense characters and press the enter key.

[me@linuxbox me]$ kdkjflajfks

If all went well, you should have gotten an error message complaining that it cannot understand you:

[me@linuxbox me]$ kdkjflajfks

bash: kdkjflajfks: command not found

Wonderful! Now press the up-arrow key. Watch how our previous command "kdkjflajfks" returns. Yes, we have command history. Press the down-arrow and we get the blank line again.

Recall the "kdkjflajfks" command using the up-arrow key if needed. Now, try the left and right-arrow keys. You can position the text cursor anywhere in the command line. This allows you to easily correct mistakes.

You're not logged in as root, are you?

Don't operate the computer as the superuser. You should only become the superuser when absolutely necessary. Doing otherwise is dangerous, stupid, and in poor taste. Create a user account for yourself now!

Using the Mouse

Even though the shell is a command line interface, you can still use the mouse for several things. That is, if you have a 3-button mouse; and you should have a 3-button mouse if you want to use Linux.

First, you can use the mouse to scroll backwards and forwards through the output of the terminal window. To demonstrate, hold down the enter key until it scrolls off the window. Now, with your mouse, you can use the scroll bar at the side of the terminal window to move the window contents up and down. If you are using xterm, you may find this difficult, since the middle button is required for this operation. If you have a 2-button mouse, it may have been configured to emulate a 3-button mouse. This means the middle button can be simulated by pressing down both the left and right buttons at the same time.

Next, you can copy text with the mouse. Drag your mouse over some text (for example, "kdkjflajfks" right here on the browser window) while holding down the left button. The text should highlight. Now move your mouse pointer to the terminal window and press the middle mouse button. The text you highlighted in the browser window should be copied into the command line. Did I mention that you will need a 3-button mouse?

A few words about focus...

When you installed your Linux system and its window manager (most likely Gnome or KDE), it was configured to behave in some ways like that legacy operating system.

In particular, it probably has its focus policy set to "click to focus." This means that in order for a window to gain focus (become active) you have to click in the window. This is contrary to traditional X windows behavior. If you take my advice and get a 3-button mouse, you will want to set the focus policy to "focus follows mouse". This will make using the text copying feature of X windows much easier to use. You may find it strange at first that windows don't raise to the front when they get focus (you have to click on the title bar to do that), but you will enjoy being able to work on more than one window at once without having the active window obscuring the the other. Try it and give it a fair trial; I think you will like it. You can find this setting in the configuration tools for your window manager.