Pages

Jumat, 11 November 2011

UNIX系统操作入门篇 UNIX system operation Beginners 第一讲 Lecture

这篇东西是关于Unix系统操作的教程。 This thing is a tutorial on the Unix operating system. 也是Unix的入门教程。 Is the Unix Tutorial. 如果你有兴趣学,请看下去,保证你可以学到许多有用的东西。 If you are interested in learning, see down to ensure that you can learn many useful things. 如果你满足于dos,windows的操作,不想对网络服务器,有任何了解的话,可以不看。 If you are satisfied with dos, windows operation, do not want on the network server, any understanding, you can not see. 因为你并不想成为计算机高手。 Because you do not want to be a computer expert. 本教程仅仅讲授Unix系统的常用命令,不涉及Unix的历史、安装和编程。 This tutorial only teach common Unix system command, does not involve the history of Unix, installation and programming. 如果你想得到更多的知识, 请查找其他的教材。 If you want more knowledge, please look for other materials. 本教程参考了《精通Unix》、《Unix基础》、《Unix系统使用指南》等书,你可以在那里找到更多的知识。 This tutorial reference to the "master Unix", "Unix based", "Unix System User Guide" and other books, where you can find more knowledge.
准备知识: Ready knowledge:

Unix是一个多任务多用户的操作系统。 Unix is ​​a multi-tasking multi-user operating system. 多任务是指可以同时运行几个不同的程序,或命令。 Multi-task is one that can run several different programs, or commands. 在操作系统的术语里叫“进程”,就象在运行Windows95的时候我们可以一边听CD 一边打字,同时打印机还在工作。 In terms of the operating system called "process", as in running Windows95 when we can listen to the CD while typing, while the printer is still working. 多用户是指一台运行Unix系统的机器可以同时具有几个不同的输入输出设备,给几个,几十个用户同时使用。 Is a multi-user systems running Unix machine can have several different input and output devices, to a few, dozens of simultaneous users. 不同的输入输出设备我们称为终端。 Different input and output devices we call the terminal. Unix给每个终端设置不同的序号以协调工作,这个序号被称为终端序号。 Unix to set a different number for each terminal to coordinate the work, this number is called the terminal number. Unix是一个根本不同于Dos的系统,无论其命令格式,用途都和Dos有很大区别。 Unix is ​​a fundamentally different from the Dos system, regardless of their command format, and Dos uses are very different. 比如: 目录分割符是"/",而不是"\"。 For example: directory separator is "/" instead of "\." 具体的不同请参考其他书籍。 Please refer to the different specific other books.

开始练习之前: Before starting to practice:

在开始教授Unix命令之前,请先记下这个地址:http://www.cyberspace.org。 Professor at the beginning of the Unix command before you write down this address: http://www.cyberspace.org. 它是一台在美国的,连上Internet的Unix主机。 It is the one in the United States, Unix hosts connected to the Internet. 之所以告诉大家这个地址是因为它提供免费的帐号供大家使用。 The reason to tell you this address because it offers free account for your use. 是免费的。 Is free. 就是说你可以先去那里申请一个帐号,然后在那里练习你所学到的Unix命令。 That is where you can go to apply for an account, then practice what you learn where the Unix command. 因为我相信不是每个朋友都可以轻松地得到Unix帐号的。 Because I believe that not every friend can easily get Unix account. 在你成功的申请好帐号之后,请在你Windows95的dos窗口里输入"telnet cyberspace.org" 等待连上主机。 Good in your account after a successful application, you Windows95 in the dos window type "telnet cyberspace.org" waiting to connect to the host. 接下来就是输入你的用户名和密码,不要告诉我这些你都不会,如果你不会的话,你是怎么连到这个网页的? The next step is to enter your user name and password, do not tell me you are not, if you do not, then how do you link to this page? 现在假定你连上了主机,系统的提示符应该是"cyberscpae.org%",对这个就是提示符就象dos里的"c:\>"。 Now suppose you connect to the host system prompt should be "cyberscpae.org%", this is like the dos prompt in the "c: \>". 接下去我将开始命令篇。 Next chapter I will start the command.

ls ls

你记不记得你学会的第一个Dos命令? Do you remember the first one you learn Dos command? 反正我学会的第一个命令是dir:列目录和文件的命令。 Anyway, I learned the first command is dir: command-line directories and files. 你学会的第一个Unix的命令也是列目录和文件的命令ls. 功能列出当前目录下的文件和目录。 You learn the first Unix command is a command line directory and file ls. Function lists the current directory of files and directories. 同Dos一样,Unix系统命令也是带参数的。 Like with Dos, Unix system command is parameterized. ls的参数有"a","l","F"。 ls of the parameters "a", "l", "F". 请注意,F是大写。 Please note, F is the capital. Unix系统里对命令的大小是严格区分的。 Unix systems the size of the command is strict distinction. (所以我们做网页常常会发生连接错误)同dos 不一样的地方在于,Unix命令的参数是"-"为其前导,而不是"/"。 (So ​​often we do web connection error occurred) where the same is not the same as dos, Unix command parameters "-" for leading, instead of "/." 所以完整的ls命令是 Therefore, the ls command is complete

ls -l -a -F或ls -laF ls-l-a-F or ls-laF

-l:long的意思,把文件的其他资料,如文件长度,上次修改的日期等等列出来。 -L: long meant to document other information, such as file size, last modification date, etc. listed.

-a:all的意思,把本目录下所有的文件,包括隐含的文件也列出来。 -A: all means, the catalog of all files, including hidden files are also listed.

-F:显示文件类型。 -F: display file type. "*"表示可执行文件,"/"表示目录,"@"表示连接。 "*" Indicates an executable file, "/" means directory "@" indicates the connection.

好,请在你的机器上输入ls -l -a -F,或许这是你一生里第一个Unix命令。 Yes, please enter your machine ls-l-a-F, perhaps this is the first of your life in a Unix command. 记住了吗? Remember it?

cd cd

变换目录,和Dos相同。 Change the directory, and Dos same. 如果你在cd后面没有给定目的地,则表示目的地是家目录。 If you are not given in the cd back destination, then the destination is the home directory. 在unix中有三中表示目录的符号".","..","~"。 There are three in the unix directory notation ".","..","~"。 said "."表示当前目录路径的位置".."表示当前路径的上一层目录,或称"父目录" "~"表示家目录,所谓家目录指系统管理员分配给你的目录,比如你的用户名是li,那么你的家目录就是在"~li",在cd后面加上"~li"就是去你的家目录。 "." Indicates the location of the current directory path ".." indicates that the current path of the parent directory, or "parent directory" "~" means home directory, so-called home directory is the system administrator assigned to your directory, such as you The user name is li, then your home directory is "~ li", the cd followed by "~ li" is to your home directory.

date date

显示出当前的时间和日期,记住在Unix里你是无法修改系统时间的。 Shows the current time and date, remember to Unix, you can not modify the system time. 输出时间一般是格林威志时间。 Output time is generally Greenway blog time.

who who

该命令告诉你现在你使用的系统里有哪些用户。 This command tells you the system you are using which users. Unix是一个多用户的操作系统,同时在机器上的可能有数十甚至数百人。 Unix is ​​a multi-user operating system, while on the machine may have dozens or even hundreds of people. who命令可以把他们的名字和终端号都列出来。 who command their names and terminal numbers are listed. who命令有一个比较有趣的用法,"who am I"如其字面上的意思,让Unix显示你的用户名和终端类型 who command a more interesting usage, "who am I" as its literal meaning, so Unix display your user name and terminal type

more more

more命令有点象Dos里的Type命令,就是显示文本文件的内容。 command a bit more like the Type command in Dos is the contents of text files. 比如你要显示文件file1的内容,可以用: more file1 当要看的文件超过屏幕可以容纳的行数,就会在屏幕的左下角出现一个"--More--"并告诉你已经看过了整个文件的百分之几。 For example, you want to display the contents of the file file1, you can use: more file1 When the file to see the screen can accommodate more than the number of lines will appear in the lower left corner of the screen a "- More -" and tell that you've seen a few percent of the entire file. 如果要继续看下去,就敲"Space Bar",可以看下一页, 或用"Enter",就会读入下一行。 If you want to keep reading, you knock "Space Bar", you can see the next page, or use the "Enter", it will read the next line. more命令还可以由你指定开始的行数。 The more command can also be started by a number of lines you specify. 比如file1文件有1000行,你已经看过100行,那么可以用"more +100 file1"则直接从第100行开始看起。 Such as the file1 file has 1000 lines, you've seen 100 lines, then you can use "more +100 file1" line directly from the first 100 began to read. 还有可以在命令里指定关键字。 There can be specified in the command keyword. ore +/key_word 这样写,more就会从含有"key_word"字样的那一行的前两行开始显示。 ore + / key_word like this, more will be from containing "key_word" the word line of the first two lines beginning to show. 也许你已经注意到,Unix里对文本文件的操作要比Dos强大的多,实际上的确如此。 Perhaps you have noticed, Unix text files in the operation of more than Dos powerful, in fact, true.

第二讲 Lecture

cp cp

cp命令同dos里的copy命令是一样的,复制文件。 cp command in the dos copy command with the same, copy the files. 比如: For example:

cp file1 file2 cp file1 file2

注意,如果你当前目录里已经含有file2这个文件,这个操作将会覆盖原来的file2。 Note that if your current directory already contains the file file2, this operation will overwrite the original file2. 也许在Dos里不会这样,它会要你确认。 Perhaps not in the Dos in this way, it will ask you to confirm. 但你现在在用Unix,在你没有叫它确认之前,它不会那么做。 But you are now in use Unix, you do not call it confirmation, it will not do that.

cp -i file1 file2 cp-i file1 file2

当你使用了-i这个选项,再遇到重名的情况系统将要你确认是否继续。 When you use the-i This option, then the situation encountered the same name you confirm whether the system will continue. cp命令还有两个比较重要的选项:-r -p cp command there are two more important options:-r-p

cp -r /dir1 /dir_temp 这条命令是将目录dir1完全地复制到目录/dir_temp里,在Dos里着条命令叫xcopy cp-r / dir1 / dir_temp This command is completely copied to the directory dir1 directory / dir_temp, in the Dos xcopy in a command called

cp -p file1 file2 cp-p file1 file2

Unix的系统和dos有一个不同的地方,在dos里copy一个文件是不会改变它的文件修改时间的,除非你确实那样做了。 Unix systems and dos have a different place, where copy a file in dos will not change its file modification time, unless you really like to do. 在Unix里不同,它要改你的时间,或许它认为cp也是一种修改吧。 Different in Unix, it is to change your time, perhaps it is that cp is a change it. 当你加上-p以后就不会改时间了。 When you add the-p will not change after time.

用惯Dos的人或许会对下面的一行命令大惑不解: Perhaps people are used to Dos line command would be puzzled by the following:

cp file1 file2 file3 dir_dest 这条命令把file1,file2,file3三个文件一起复制到/dir_dest里去。 cp file1 file2 file3 dir_dest this command to file1, file2, file3 with the copy three files to / dir_dest go.

好了今天就讲到这里,最后留一个思考题,请说明一下下面一行命令的作用,请不要用Dos 的思考方式。 Well today will stop here, leaving a final reflection questions, please explain the following line of work, please do not use Dos way of thinking. 我们下个星期再见。 We next week bye.

思考问题,请说出以下命令的作用: Thinking, please state the role of the following commands:

cp file1+file2 file3 cp file1 + file2 file3

cp cp
上个星期我提出的问题你能解吗? Last week I raised the question you can answer it? 实际上以下命令的意义是这样的: In fact the meaning of the following command is this:

cp file1+file2 file3 cp file1 + file2 file3

表示将一个名字为file1+file2的文件拷贝成file3。 That the name of a file copy file1 + file2 into file3. 而不是在dos里的将file1和file2加在一起拷贝成文件file3。 Rather than in the dos together will copy file1 and file2 into file file3. 在unix的文件系统里,文件名字可以到255或254个字符,具体要看你到底使用那种类型的 In the unix file system, file name can go to 255 or 254 characters, depending on the type of use you in the end

Unix。 Unix.

cat cat

这个命令可不是“猫”的意思,而是catenate的缩写。 This command is not "cat" means, but catenate abbreviation. 顾名思义,是把东西串起来。 As the name suggests, is to string things together. 比如: For example:

cat file1 file2 cat file1 file2

就是把文件file1和file2连在一起,然后输出到屏幕上。 File1 and file2 is the file together, and then output to the screen. 注意,输出到屏幕上是cat的自定义目的。 Note that the output to the screen is a cat custom purposes. 如果要改变它的输出方向,就必须使用Unix系统的输出重定向符“>” If you want to change the direction of its output, you must use Unix system output redirection symbol ">"

> >

输出重定向符。 Output redirection symbol. 稍微高级一点的dos用户都知道这个符号。 A little bit of dos advanced users are aware of this symbol. 在Unix里的用法同Dos的区别不是很大。 With the use of Unix, Dos's not a big difference. 但比较不同的地方是,Unix系统将任何的一个外设都认同为一个文件。 But to compare different places, Unix systems will agree to any of a peripheral to a file. 所以如果你要将输出重定向到打印机之类的地方,只要写上代表打印机的设备文件名。 So if you want to redirect the output to a printer like the place, just write on behalf of the printer device file name. 前一将里我们曾讲过终端机器名,它也是一个文件。 Previous years we have talked about the terminal machine name, it is also a file. 比方我的设备机器是ttya,而小李的设备机器是ttyb,他想让我把当前目录的内容给他看。 For example, my machine is a device ttya, and Mike's equipment and machinery is ttyb, he wanted me to put the current directory contents to him. 那么用这条命令就可以了 Then use this command on

ls -auF >ttyb ls-auF> ttyb

这充分利用了Unix系统多用户的设计思想。 It takes full advantage of multi-user Unix system design.

同样的使用ls -auF>file1就是将当前目录列表输出到file1中。 The same use ls-auF> file1 is the current output to file1 in the directory list.

又比如: Another example:

cat file1 file2>file3 cat file1 file2> file3

就是将文件file1和file2的内容输出到file3中。 Is to document the contents of file1 and file2 to file3 in the output. 在Dos里这条命令被写成copy file1+file2 file3 In Dos command is written in this copy file1 + file2 file3

当你用'>'来输出重定向的时候,系统马上打开一个空文件来准备存放'>'之前那个文件命令的输出结果。 When you use the '>' to redirect the output when the system is immediately ready to open an empty file to store '>' the file before the command output. 比如: For example:

cat file1 file2>file3 cat file1 file2> file3

系统先将file3的内容清空。 Empty the contents of the system first file3. 所以: So:

cat file1 file2>file1这条命令将产生一个错误提示。 cat file1 file2> file1 This command will generate an error message. 也许这条命令的本意是增加file1里的内容,但在系统初始这条命令的时候就把file1里的内容清空了。 Perhaps the intention of this command is to increase the contents of file1, but this command in the system when initially put the contents of file1 cleared. 所以你得到一个错误提示。 So you get an error message. 如果要追加文件内容请使用以下命令: If you want to append the file, please use the following command:

cat file2>>file1 cat file2>> file1

">>"表示追加,而不是先清空file1中的内容。 ">>" Indicates an additional, and not to empty the contents of file1.

上面讲的是输出重定向,还有输入重定向。 Mentioned above is the output redirection, input redirection there. 这个留在以后讲。 The remaining speakers in the future.

man man

是英语"manual"的缩写。 English "manual" abbreviation. 这是一条使用频率很高的命令,用来得到系统对一个特定命令的帮助信息。 This is a high frequency of use of the command system to get help with a specific command. 请各位读者一定要掌握这条命令。 Readers please be sure to master this Order.

格式为:man -k 命令关键字 Format: man-k keyword command

mv mv

这个命令是move的缩写,就是把一个目录或文件搬来搬去。 The move command is the acronym is to a directory or file moved around. 实际上我常把它当成改文件名字的命令来用。 In fact I often use it as a command to change the file name to use. 比如: For example:

mv file1 ABC就是把文件file1改成ABC。 mv file1 ABC is to file file1 into ABC.

rm rm

记住rm是remove,是清除文件的意思。 Remember rm is remove, the meaning is clear file. 在Unix里是没有undelete这会事情的,所以请在使用的时候加上-i这个选项。 In Unix, there is no undelete it would matter, so use this time with the-i option. 表示确认。 Said confirmation.

在这个星期我们的Unix教程就到这里了。 In this week we went to a Unix tutorial here. 有许多朋友写信告诉我无法使用cyberspace的unix,也许是那里的速度比较慢。 Many friends wrote and told me not to use cyberspace for unix, there may be slow. 如果你实在没地方练习unix命令,我向你推荐一个工具,叫unixdos。 If you really is no place to practice unix commands, I recommend to you a tool, called unixdos. 它是一个unix环境的dos模拟器,基本上常用的unix命令你都可以使用。 It is a unix environment, dos emulator, basically common unix commands you can use. 有兴趣的朋友请写信给我,我告诉你在那里下载。 Friends who are interested, please write to me, I told you to download.

第三讲 The third talk

文件权限 File permissions

各位读者,经过上两个星期的热身,我们开始渐渐接近Unix操作的核心。 Our readers, after two weeks of warm-up, we started getting close to the Unix operating core. 在本周我们着重谈谈Unix的文件系统,下次再讲vi编辑器。 This week we focus on a Unix file system, the next revisit the vi editor.

现在我们来看一个示例: Now we look at an example:

Username:unixfree Username: unixfree

Password:******** Password :********

(登陆到Unix) (Log in to Unix)

%:ls -l(显示文件表) %: Ls-l (shows file table)

drwxr-xrw- 1 unixfree project1 128 Apr 4 12:19 dir drwxr-xrw-1 unixfree project1 128 Apr 4 12:19 dir

-rw-r--r-- 1 unixfree project1 545 Apr 4 12:19 file1 -Rw-r - r - 1 unixfree project1 545 Apr 4 12:19 file1

lrwxrwxrwx 1 unixfree project1 124 Jan 13 09:01 file2-->file3 lrwxrwxrwx 1 unixfree project1 124 Jan 13 09:01 file2 -> file3

-rw------- 1 unixfree project1 212 Jul 22 14:23 file3 -Rw ------- 1 unixfree project1 212 Jul 22 14:23 file3

在文件列表最前边的就是文件的属性。 In the file list is the most front file attributes. 一般来说,它有十个小项目,也就是十个符号。 In general, it has ten small projects, that is, ten symbols. 它们以1+3+3+3的方式表示四个意义: 1 +3 +3 +3 them to the way in four meanings:

文件类型(1)、文件拥有者(user)对此文件的权限(3)、同组者(group)对此文件 File type (1), the file owner (user) permission to this document (3), the same group by (group) on this file

的权限(3)、其他人(others)对此文件的权限(3)。 Permissions (3), others (others) permission to this document (3).

文件类型:文件类型有三种符号,分别为: File Type: File Type There are three symbols, namely:

"-":普通文件 "-": A regular file

"d":目录 "D": directory

"1":表示连接(下面会详细讲) "1": indicates that the connection (speak in more detail below)

文件权限:文件的权限也有三种 File permissions: file permissions, there are three

"r":只读文件 "R": read-only file

"w":可写文件 "W": writable files

"-":不可执行文件,不可读文件,不可写文件 "-": Non-executable files, unreadable files, can not write file

"x":可执行 "X": Executable

在Unix系统里用户是分组的,就象NT的分组一样。 On Unix systems users group, the same as the NT group. 一般来说同一组的人往往比较接近,比如公司的同一个部门就是一个组。 Generally speaking, the same group of people tend to close, such as the company is a group of the same department. 而不同组的人则不在同一个组。 The different groups of people are not in the same group. 分组情况是由系统管理员制定的。 Group is established by the system administrator. 普通用户不能自行更改。 Ordinary users can not make changes.

所以在上面的例子里的第一行表示该目录User可读可写可执行,本组的用户可读不可写可执行,其他用户可读可写不可执行。 So in the example above the first line indicates that the catalog User read-write executables, this group of users can not write readable executable, other users read and write can not be executed. 其他的你就自己解释吧。 Others you have to do to explain it.

前面我提到了一个文件类型"1"。 Earlier I referred to a file type "1." 这是比较特别的类型,它只是一个门牌,任何对它的访问都会自动到它指向的文件。 This is a rather special type, it is just a number plate, any access to it will automatically file it points to. 比如上例中我们看到file2是连向file3的一个文件,那么任何对file2的操作都是对file3的操作,并且文件的实际属性是file3的属性,而不是file2的属性。 In the example above we see that even to file3 file2 is a file, then any of file2 file3 operations are operating on, and the real property is file3 file properties, attributes, rather than file2.

改变文件属性的命令:chmod Command to change file attributes: chmod

chmod 是chang mode的缩写,用来改变文件的权限。 chmod is chang mode abbreviation, used to change file permissions. 用以下的文件为例: File with the following example:

-rw-r--r-- 1 unixfree project1 545 Apr 4 12:19 file1 -Rw-r - r - 1 unixfree project1 545 Apr 4 12:19 file1

第一个"-"表示本文件是一个普通的文件。 The first "-" indicates that this file is an ordinary file. "rw-"表示文件拥有者对此文件的权限为可读可写不可执行。 "Rw-" said the owner of the file permissions for this file readable and writable unenforceable. 其他的你自己看了。 You read the other.

要改变次文件的权限,比如我怕将此文件改坏掉,所以希望自己不可写此文件chmod uw file1 To change the time the file permissions, for example, I'm afraid to change this file broken, so I hope its not to write this file chmod uw file1

符号"u"表示文件的拥有者,"g"表示同组者,"o"表示其他用户,"a"表示全体用户,就是前面讲的所有的人。 Symbol "u" ​​indicates the file's owner, "g" with the group who said, "o" that other users, "a" that all users, that is, speaking in front of all people. "-"表示去掉某个属性,"+"表示加上某个属性。 "-" Indicates removing an attribute, "+" means add an attribute.

又比如我要讲file1改成全体用户都可读可写可执行的文件: Another example I want to say all users can read file1 into executable files can be written:

chmod a+rwx file1 chmod a + rwx file1

然后去掉其他用户执行的权利: Then remove the right to perform other users:

chmod ox file1 chmod ox file1

你懂了吗? You understand it? 如果你有兴趣,快去试试吧。 If you are interested, go and try it. 我们下周开始讲令人厌烦的vi。 Next week we start talking about boring vi. Bye!这个教程是为一些没有机会接触Unix的网友写的。 Bye! This tutorial is no access for some users of Unix written. 目的是为了让大家能够有些感性的认识。 Purpose is to allow everyone to some perceptual awareness. 如果你没有Unix帐号可以使用,请去http://www.cyberspace.org申请一个免费的Unix帐号。 If you do not have Unix accounts can use, please go to http://www.cyberspace.org for a free Unix account. 或者在网络上找一个叫UnixDos的软件来将你的Dos Or on the network to find a software called UnixDos to your Dos
模拟成Unix环境。 Simulate a Unix environment. 或者将你的Win格式掉,装一个Linux。 Win or format of your out, install a Linux. :-) :-)

第四讲 Fourth Lecture

各位细心学习的朋友,非常感谢你能继续看这个教程。 You carefully study the friends, thank you very much to continue to look at this tutorial. 这个星期我们开始学习VI编辑器。 This week we started to learn VI editor. 从功能上说它是一个同EDIT基本一样的工具,但是它非常难学! It is functionally the same as a basic tool with EDIT, but it is very difficult to learn! 以至于在现在我不得不引用一句在unix初学者口中的话来告戒大家"To vi or not to vi,that is a question"! So now I have to refer to a beginner in unix to caution you mouth the words "To vi or not to vi, that is a question"!
Vi的模式: Vi mode:
Vi有两种基本模式:命令模式和编辑模式,他们以键切换。 Vi has two basic modes: command mode and edit mode, they key switch.
OK,我们启动一下vi,看看这么使用这个工具。 OK, we start about vi, to see so use this tool.
%vi % Vi
启动vi,第一件事先按,记得你在vi里要常常用它。 Start vi, the first thing press , remember that you often use in vi to it. 然后输入"i"。 Then enter "i".
屏幕上绝对不会出现任何字,因为后你在命令模式,输入"i"则表示你进入编辑模式,并且现在的状态是insert,就是插入文本。 Will not appear on the screen any word, because after you command mode, type "i" indicates that you enter the edit mode, and now the state is insert, is to insert text.
如果你还没有被搞糊涂,那么继续输入。 If you are not confused, then continue typing.
I love Unix. I love Unix.

是的,屏幕上出字了,你顺利地输入第一行文字。 Yes, the word appears on the screen, you successfully enter the first line of text. 现在我们要保存这个文件。 Now we want to save this file. 再按一次,到命令模式,输入":w",表示存盘。 Press , to command mode, type ": w", said Save. 你也可以输入 You can also enter
":w Unix.txt",那么就是以Unix.txt为文件名字存盘。 ": W Unix.txt", then the file name is to Unix.txt Save.
好了基本vi概念就是如此。 Well the concept is so basic vi. 我把常用的一些命令都写在下面,你自己试着输入吧。 I used some of the commands are written in the following, you try to enter it.


i牋"insert"的缩写在光标之前插入文字 i Jian "insert" be inserted before the abbreviation in the text cursor
a牋"append"的缩写在光标之后插入文字 a memo an "append" inserted after the abbreviation in the text cursor
o "open"的缩写在光标所在行的下面开始新一行的输入 o "open" stands in the line below the cursor to start a new line of input
O "Open"的缩写在光标所在行的上面开始新一行的输入 O "Open" stands above the line where the cursor to start a new line of input
I?/TD> "Insert"的缩写在本行最前面开始输入文字 I? / TD> "Insert" stands in our front began to enter text
A "Append"的缩写在本行最后开始插入文字 A "Append" the beginning of the final abbreviation to insert text in the Bank
dd?/TD> 删除光标所在的那行 dd? / TD> delete the line where the cursor
dw 删除光标所在的那个字 cursor dw delete word
dnw? 删除光标所在字和其后的n个字(n为正整数) dnw? the cursor to delete the word and subsequent words of n (n is a positive integer)
x? 删除光标所在的那个字母 x? the cursor to delete that letter
:w? 存文件 : W? Save file
:r? 读文件 : R? Read the file
:q? 退出vi : Q? Quit vi

上面都是一些基本的用法,如果还不够,请使用man命令查询。 The above are some basic usage, if it is not enough, use the man command to query.
好了就这样吧。 Well, so be it. 我们下个星期见。 We see next week. 进行unix的Shell概述。 For the unix Shell Overview.

第五讲 Fifth Lecture

本周的Unix教程是最后一讲了。 This week's Unix tutorial is the last talk about it. 在本讲里我们将讲一下unix Shell的基本内容。 In this lecture we'll talk about the unix Shell's basic elements. 我不准备深入地讲解Shell编程。 I'm not going to explain in depth Shell programming. 因为要是那样的话,足够写上五十个page. Shell是外层,是用户与Unix之间的层,它们节省命令行的长度,对命令参数执行完整的变换,并且定位和解释用户命令。 Because if that case, enough to write fifty page. Shell is the outer layer is a layer between the user and Unix, they save the command line length, the command parameters to perform a complete transformation, and to locate and interpret the user command. 另一方面,shell也是一个功能强大的程序语言,提供制作工具的工厂。 On the other hand, shell is a powerful programming language, providing the production tools factory. 用Shell能创建用户自己的命令,甚至创建一个完整的新环境。 Shell can be used to create your own commands, or even create a completely new environment.
在程序员里有一个流行称谓“如果你不喜欢Unix界面,就自己写一个”。 The programmer there is a popular title, "If you do not like the Unix interface, you write your own." 实际上无需深入到内核,便可以方便地控制自己的界面。 In fact without deep into the core, they can easily control their own interface. 可选的Shell有sh,csh,ksh有强大的功能。 Optional Shell have sh, csh, ksh has powerful features.

正如其名字,Shell Script是一个文本文件。 As its name, Shell Script is a text file. 该文件指挥并控制Shell执行一系列特定的操作。 Shell command and control of the file execute a series of specific actions. 一个批处理文件能含有任何命令(Unix的内部和外部命令),还可以包括过去编写的批处理文件。 A batch file can contain any command (Unix internal and external command), you can write batch files, including the past.

第一个Shell处理文件: The first Shell handle the file:
这里使用的Shell是BS,如果你是使用CS可以更改一部分内容。 Shell used here is BS, if you are part of the CS can be changed.
: :
#@(#)dw--show data and users-- #@(#) Dw - show data and users -
# #
date date
who -u who-u
第一个:不是必须的,而是长期的习惯。 The first: It is not necessary, but long-term habit. 它告诉系统下面是BShell的内容。 It tells the system the following is BShell content.

正如你看到的,Unix的Shell文件和Dos的批文件在很多地方是相同的。 As you can see, Unix Shell files and the batch file Dos is the same in many places. 在写Unix的Shell文件时候,我们一般使用六个步骤: Write files in the Unix Shell, we generally use the six steps:
1.计划好命令系列,并在键盘上试用 1 planned command line, and the trial on the keyboard
2.为批处理文件挑一个好的,不会发生重复的文件名 (2) a good pick for the batch file, the file name does not duplicate
3.用你喜欢的编辑工具生成文件(希望不是VI:-)) 3, with your favorite editing tool file (hope not VI :-))
4.从冒号开始文件,以增加文件的解释 4 from the colon to start the file, add files to the interpretation of
5.用Chmod命令,将文件的属性设置为可读文件 5 with the Chmod command, the file attribute is set to readable files
6.把批处理文件放入适合的目录中。 6 the batch file into the appropriate directory.

以上是Unix系统的Shell文件一些基本的内容。 Shell is a Unix system over some of the basic contents of the file. 这里就不多说了,实际上Shell文件同我们这些写网页的人关系并不大,但知道一些还是好的。 This is not to say, in fact, Shell document pages with those of us who write does not matter much, but know that some still good.

持续五周的Unix系统操作教程已经写完了。 Last five weeks of Unix systems tutorial has been finished. 如果你觉得有必要深刻了解一下Unix系统,请查找一些书本。 If you feel the need to deeply understand the Unix system, look for some books.

Tidak ada komentar:

Posting Komentar