Lts0010:修订间差异

来自Ubuntu中文
跳到导航跳到搜索
Wanglijuncode留言 | 贡献
无编辑摘要
Wanglijuncode留言 | 贡献
无编辑摘要
第16行: 第16行:


  让我们开始测试吧, 打开一个 terminal终端窗口,您会看到一个shell提示符,这个提示符包括您的用户名、机器名、$.就像下面这样:  
  让我们开始测试吧, 打开一个 terminal终端窗口,您会看到一个shell提示符,这个提示符包括您的用户名、机器名、$.就像下面这样:  


  <code>[usrname@machinename]$: </code>
  <code>[usrname@machinename]$: </code>


   随便输入一些字符试试看。
   随便输入一些字符试试看。
<code>[usrname@machinename]$: kdkjflajfks</code>  
<code>[usrname@machinename]$: kdkjflajfks</code>  


如果一切顺利的话,您会看到系统返回的一些无法理解的错误提示:  
如果一切顺利的话,您会看到系统返回的一些无法理解的错误提示:  


<code>[usrname@machinename]$: kdkjflajfks </code>  
<code>[usrname@machinename]$: kdkjflajfks </code>  


<code>bash: kdkjflajfks: command not found </code>  
<code>bash: kdkjflajfks: command not found </code>  


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? ==
== You're not logged in as root, are you? ==

2008年6月28日 (六) 13:15的版本

什么是Shell?

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

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

Xterm、 Gnome、Konsole之类都是什么?


这些都是所谓的“终端模拟器”,这是一些可以让您的计算机界面变得易于操作,并解可以帮助您和对话的程序。现在有很多的终端模拟器供我们使用。一般的Linux系统通常包含多种终端模拟器,就像:xterm、rxvt、konsole、kvt、gnome-terminal、nxterm、eterm.

启动终端

您的窗口管理器可以通过菜单来启动程序,查看程序清单,您也许会发现一个像终端模拟器的程序。 在 KDE中,在主菜单中,终端模拟器通常是 Konsole和Tterminal.而在 Gnome中,您发现的却是"color xterm"、 "regular xterm,"和 "gnome-terminal". 您可以随意的启动这些终端模拟器, 尝试不同模拟器。他们都可以给您一个访问shell的对话。 You will probably develop a preference for one, based on the different bells and whistles each one provides.

测试键盘

让我们开始测试吧, 打开一个 terminal终端窗口,您会看到一个shell提示符,这个提示符包括您的用户名、机器名、$.就像下面这样: 


[usrname@machinename]$: 
 随便输入一些字符试试看。


[usrname@machinename]$: kdkjflajfks

如果一切顺利的话,您会看到系统返回的一些无法理解的错误提示:

[usrname@machinename]$: kdkjflajfks

bash: kdkjflajfks: command not found

如果您安 键盘向上的箭头,您会惊奇的发现,我们以前输入的字符被保存了,并且有个一个历史记录。

如果我们需要,可以调用历史记录的命令,现在试试向右的箭头,您会发现光标在向右移动,通过这个操作我们可以轻易的修改错误。

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.