(window.webpackJsonp=window.webpackJsonp||[]).push([[57],{343:function(t,a,s){"use strict";s.r(a);var e=s(14),v=Object(e.a)({},(function(){var t=this,a=t._self._c;return a("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[a("h1",{attrs:{id:"lab-1-熟悉类linux系统的命令"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#lab-1-熟悉类linux系统的命令"}},[t._v("#")]),t._v(" Lab-1 熟悉类Linux系统的命令")]),t._v(" "),a("h2",{attrs:{id:"本章导读"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#本章导读"}},[t._v("#")]),t._v(" 本章导读")]),t._v(" "),a("p",[t._v("本章意在介绍Linux系统的常用命令,要求掌握Linux一般命令格式,学会使用man命令来寻求帮助,学习使用命令对有关文件和目录进行操作,利用vi编辑器建立、编辑、显示及加工处理文本文件。")]),t._v(" "),a("h2",{attrs:{id:"帮助命令"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#帮助命令"}},[t._v("#")]),t._v(" 帮助命令")]),t._v(" "),a("h3",{attrs:{id:"man命令-显示联机帮助手册"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#man命令-显示联机帮助手册"}},[t._v("#")]),t._v(" "),a("code",[t._v("man")]),t._v("命令:显示联机帮助手册")]),t._v(" "),a("p",[t._v("Linux的命令有很多参数,我们不可能全记住,我们可以通过man命令查看联机手册获取帮助。\n格式:man 命令")]),t._v(" "),a("div",{staticClass:"language-shell extra-class"},[a("pre",{pre:!0,attrs:{class:"language-shell"}},[a("code",[a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 显示出ls命令的功能及选项的含义")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("man")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("ls")]),t._v("\n")])])]),a("h3",{attrs:{id:"help命令-显示帮助信息"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#help命令-显示帮助信息"}},[t._v("#")]),t._v(" "),a("code",[t._v("help")]),t._v("命令:显示帮助信息")]),t._v(" "),a("p",[t._v("同时,也可以使用"),a("code",[t._v("help")]),t._v("命令查看帮助信息.")]),t._v(" "),a("div",{staticClass:"language-shell extra-class"},[a("pre",{pre:!0,attrs:{class:"language-shell"}},[a("code",[a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 显示出ls命令的功能及选项的含义")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token builtin class-name"}},[t._v("help")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("ls")]),t._v("\n")])])]),a("h2",{attrs:{id:"简单命令"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#简单命令"}},[t._v("#")]),t._v(" 简单命令")]),t._v(" "),a("h3",{attrs:{id:"date命令-显示时间"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#date命令-显示时间"}},[t._v("#")]),t._v(" "),a("code",[t._v("date")]),t._v("命令:显示时间")]),t._v(" "),a("p",[t._v("显示或设置系统的日期或时间")]),t._v(" "),a("h3",{attrs:{id:"cal命令-显示日历"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#cal命令-显示日历"}},[t._v("#")]),t._v(" "),a("code",[t._v("cal")]),t._v("命令:显示日历")]),t._v(" "),a("p",[t._v("显示公元1-9999年中任意一年或任意一个月的日历")]),t._v(" "),a("h3",{attrs:{id:"who命令-显示用户信息"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#who命令-显示用户信息"}},[t._v("#")]),t._v(" "),a("code",[t._v("who")]),t._v("命令:显示用户信息")]),t._v(" "),a("p",[t._v("列出所有正在使用系统的用户、所有终端名和注册到系统的时间")]),t._v(" "),a("h3",{attrs:{id:"clear命令-清除信息"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#clear命令-清除信息"}},[t._v("#")]),t._v(" "),a("code",[t._v("clear")]),t._v("命令:清除信息")]),t._v(" "),a("p",[t._v("清除屏幕上的信息")]),t._v(" "),a("h2",{attrs:{id:"文件与目录的操作"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#文件与目录的操作"}},[t._v("#")]),t._v(" 文件与目录的操作")]),t._v(" "),a("p",[t._v("对文件可以进行的操作有:复制一个文件、显示文件内容、查找指定内容、排序、文件比较、文件删除等")]),t._v(" "),a("h3",{attrs:{id:"pwd命令-显示绝对路径"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#pwd命令-显示绝对路径"}},[t._v("#")]),t._v(" "),a("code",[t._v("pwd")]),t._v("命令:显示绝对路径")]),t._v(" "),a("blockquote",[a("p",[a("strong",[t._v("基本语法")])])]),t._v(" "),a("div",{staticClass:"language-shell extra-class"},[a("pre",{pre:!0,attrs:{class:"language-shell"}},[a("code",[a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 查看当前路径")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token builtin class-name"}},[t._v("pwd")]),t._v("\n")])])]),a("h3",{attrs:{id:"ls命令-显示所有的文件和目录"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#ls命令-显示所有的文件和目录"}},[t._v("#")]),t._v(" "),a("code",[t._v("ls")]),t._v("命令:显示所有的文件和目录")]),t._v(" "),a("p",[t._v("如果未指定目录则默认显示当前目录先的所有文件和目录")]),t._v(" "),a("blockquote",[a("p",[t._v("基本语法:"),a("em",[t._v("ls 目录或文件")])])]),t._v(" "),a("div",{staticClass:"language-shell extra-class"},[a("pre",{pre:!0,attrs:{class:"language-shell"}},[a("code",[a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 查看当前路径下所有文件或目录")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("ls")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 查看当前路径下所有文件或目录的详细信息")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("ls")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[t._v("-l")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 查看当前路径下的隐藏文件")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("ls")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[t._v("-ai")]),t._v("\n")])])]),a("h3",{attrs:{id:"cd命令-切换目录"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#cd命令-切换目录"}},[t._v("#")]),t._v(" "),a("code",[t._v("cd")]),t._v("命令:切换目录")]),t._v(" "),a("blockquote",[a("p",[t._v("基本语法:"),a("em",[t._v("cd 目录")])])]),t._v(" "),a("div",{staticClass:"language-shell extra-class"},[a("pre",{pre:!0,attrs:{class:"language-shell"}},[a("code",[a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 切换到 /home 目录下")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token builtin class-name"}},[t._v("cd")]),t._v(" /a\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 切换到用户主目录")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token builtin class-name"}},[t._v("cd")]),t._v(" ~\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 切换到上一次访问的目录")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token builtin class-name"}},[t._v("cd")]),t._v(" -\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 切换到当前目录的上一级")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token builtin class-name"}},[t._v("cd")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("..")]),t._v("\n")])])]),a("h3",{attrs:{id:"mkdir命令-创建目录"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#mkdir命令-创建目录"}},[t._v("#")]),t._v(" "),a("code",[t._v("mkdir")]),t._v("命令:创建目录")]),t._v(" "),a("blockquote",[a("p",[t._v("基本语法:"),a("em",[t._v("mkdir 目录名")])])]),t._v(" "),a("div",{staticClass:"language-shell extra-class"},[a("pre",{pre:!0,attrs:{class:"language-shell"}},[a("code",[a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 创建一个 dir 目录(一级)")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("mkdir")]),t._v(" dir1\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 创建 dir1 目录,其下再创建 dir2 目录(多级)")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -p 选项用于创建多级目录")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("mkdir")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[t._v("-p")]),t._v(" dir1/dir2\n")])])]),a("h3",{attrs:{id:"rmdir命令-删除目录-空目录"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#rmdir命令-删除目录-空目录"}},[t._v("#")]),t._v(" "),a("code",[t._v("rmdir")]),t._v("命令:删除目录(空目录)")]),t._v(" "),a("blockquote",[a("p",[t._v("基本语法:"),a("em",[t._v("rmdir 目录名")])])]),t._v(" "),a("div",{staticClass:"language-shell extra-class"},[a("pre",{pre:!0,attrs:{class:"language-shell"}},[a("code",[a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 删除 home 下的dir目录")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("rmdir")]),t._v(" /home/dir\n")])])]),a("blockquote",[a("blockquote",[a("p",[t._v("mdir 删除的是空目录,目录下有内容时是无法删除的,-rf 则可删除非空目录")])])]),t._v(" "),a("div",{staticClass:"language-shell extra-class"},[a("pre",{pre:!0,attrs:{class:"language-shell"}},[a("code",[a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 强制删除 home 下的 dir 目录")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("rmdir")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[t._v("-rf")]),t._v(" /home/dir\n")])])]),a("h3",{attrs:{id:"touch命令-创建空文件"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#touch命令-创建空文件"}},[t._v("#")]),t._v(" "),a("code",[t._v("touch")]),t._v("命令:创建空文件")]),t._v(" "),a("blockquote",[a("p",[t._v("基本语法:"),a("em",[t._v("touch 文件名")])])]),t._v(" "),a("div",{staticClass:"language-shell extra-class"},[a("pre",{pre:!0,attrs:{class:"language-shell"}},[a("code",[a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 创建 hello.txt 空文件")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("touch")]),t._v(" hello.txt\n")])])]),a("h3",{attrs:{id:"cp命令-拷贝文件或目录"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#cp命令-拷贝文件或目录"}},[t._v("#")]),t._v(" "),a("code",[t._v("cp")]),t._v("命令:拷贝文件或目录")]),t._v(" "),a("blockquote",[a("p",[t._v("基本语法:"),a("em",[t._v("cp 源文件 目标文件")])])]),t._v(" "),a("div",{staticClass:"language-shell extra-class"},[a("pre",{pre:!0,attrs:{class:"language-shell"}},[a("code",[a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 拷贝 hello.txt 文件到 /tmp/files 目录中")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("cp")]),t._v(" file.txt /tmp/files\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 递归将 home 下的整个 dir1 目录拷贝到 dir2 目录下")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("cp")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[t._v("-r")]),t._v(" /home/dir1 /dir2/\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 如果连续执行相同的拷贝命令系统会一个一个提示是否覆盖文件内的文件")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 这时在 cp 前加一个 \\ 就可以进行强制覆盖,不提示")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("\\")]),t._v("cp "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[t._v("-r")]),t._v(" /home/dir1 /dir2/ \n")])])]),a("h3",{attrs:{id:"rm命令-删除文件或目录"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#rm命令-删除文件或目录"}},[t._v("#")]),t._v(" "),a("code",[t._v("rm")]),t._v("命令:删除文件或目录")]),t._v(" "),a("blockquote",[a("p",[t._v("基本语法:"),a("em",[t._v("rm 文件或目录")])])]),t._v(" "),a("div",{staticClass:"language-shell extra-class"},[a("pre",{pre:!0,attrs:{class:"language-shell"}},[a("code",[a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 删除指定的文件 file1.txt")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("rm")]),t._v(" file.txt\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 删除当前目录下的所有文件")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("rm")]),t._v(" *\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -r 递归删除 dir1 目录下的所有文件及子目录")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("rm")]),t._v(" –r dir1\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -f 强制删除文件,不提示")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("rm")]),t._v(" –f file.txt\n")])])]),a("h3",{attrs:{id:"mv命令-移动或重命名"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#mv命令-移动或重命名"}},[t._v("#")]),t._v(" "),a("code",[t._v("mv")]),t._v("命令:移动或重命名")]),t._v(" "),a("blockquote",[a("p",[t._v("基本语法:"),a("em",[t._v("mv 旧文件名 新文件名、mv /源目录 /目标目录")])])]),t._v(" "),a("div",{staticClass:"language-shell extra-class"},[a("pre",{pre:!0,attrs:{class:"language-shell"}},[a("code",[a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 将 file.txt 文件移到上层目录")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("mv")]),t._v(" file.txt "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("..")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 将 file1.txt 改名成 file2.txt")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("mv")]),t._v(" file1.txt file2.txt\n")])])]),a("blockquote",[a("blockquote",[a("p",[t._v("重命名的前提是两个文件在同一个目录下")])])]),t._v(" "),a("h3",{attrs:{id:"more命令-文本过滤器"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#more命令-文本过滤器"}},[t._v("#")]),t._v(" "),a("code",[t._v("more")]),t._v("命令:文本过滤器")]),t._v(" "),a("blockquote",[a("p",[t._v("基本语法:"),a("em",[t._v("more 要查看的文件")])])]),t._v(" "),a("div",{staticClass:"language-shell extra-class"},[a("pre",{pre:!0,attrs:{class:"language-shell"}},[a("code",[a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 查看 file.txt 文件的内容")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("more")]),t._v(" file.txt\n")])])]),a("blockquote",[a("blockquote",[a("p",[t._v("more 指令是一个基于 vim 编辑器的文本过滤器(在后面我们我谈到vim编辑器)")]),t._v(" "),a("p",[t._v("可以以全屏幕的方式按页显示文本文件的内容,且有若干快捷键:")]),t._v(" "),a("p",[a("code",[t._v("space")]),t._v("向下翻一页")]),t._v(" "),a("p",[a("code",[t._v("Enter")]),t._v("向下翻一行")]),t._v(" "),a("p",[a("code",[t._v("q")]),t._v("立即离开more,不再显示文件内容")]),t._v(" "),a("p",[a("code",[t._v("Ctrl+F")]),t._v("向下滚动以一屏")]),t._v(" "),a("p",[a("code",[t._v("Ctrl+B")]),t._v("返回上一屏")]),t._v(" "),a("p",[a("code",[t._v("=")]),t._v("输出当前行的行号")]),t._v(" "),a("p",[a("code",[t._v(":f")]),t._v("输出文件名和当前行的行号")])])]),t._v(" "),a("h3",{attrs:{id:"cat命令-查看文件内容或连接文件"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#cat命令-查看文件内容或连接文件"}},[t._v("#")]),t._v(" "),a("code",[t._v("cat")]),t._v("命令:查看文件内容或连接文件")]),t._v(" "),a("blockquote",[a("p",[t._v("基本语法:"),a("em",[t._v("cat 文件")])])]),t._v(" "),a("h3",{attrs:{id:"命令-输出重定向-追加"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#命令-输出重定向-追加"}},[t._v("#")]),t._v(" "),a("code",[t._v("> / >>")]),t._v("命令:输出重定向/追加")]),t._v(" "),a("blockquote",[a("p",[t._v("重定向 > 会覆盖之前内容,追加 >> 会将新内容添加到之前内容的末尾")])]),t._v(" "),a("div",{staticClass:"language-shell extra-class"},[a("pre",{pre:!0,attrs:{class:"language-shell"}},[a("code",[a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 和 more 命令搭配使用,逐页显示")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("cat")]),t._v(" file.txt "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("more")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 将 file2.txt 附加到 file1.txt 文件之后")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("cat")]),t._v(" file2.txt "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">>")]),t._v(" file1.txt\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 将 file1.txt 和 file2.txt 合并成 file3.txt 文件")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("cat")]),t._v(" file1.txt file2.txt "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),t._v(" file3.txt\n")])])]),a("h3",{attrs:{id:"echo命令-输出内容到控制台"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#echo命令-输出内容到控制台"}},[t._v("#")]),t._v(" "),a("code",[t._v("echo")]),t._v("命令:输出内容到控制台")]),t._v(" "),a("blockquote",[a("p",[t._v("基本语法:"),a("em",[t._v("echo 输出内容")])])]),t._v(" "),a("div",{staticClass:"language-shell extra-class"},[a("pre",{pre:!0,attrs:{class:"language-shell"}},[a("code",[a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 输出环境变量 $PATH")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token builtin class-name"}},[t._v("echo")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token environment constant"}},[t._v("$PATH")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 输出语句“Hello World”")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token builtin class-name"}},[t._v("echo")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"Hello World"')]),t._v("\n")])])]),a("h3",{attrs:{id:"head命令-显示文件开头部分"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#head命令-显示文件开头部分"}},[t._v("#")]),t._v(" "),a("code",[t._v("head")]),t._v("命令:显示文件开头部分")]),t._v(" "),a("blockquote",[a("p",[t._v("基本语法:"),a("em",[t._v("head 文件")])]),t._v(" "),a("blockquote",[a("p",[t._v("默认情况下 head 显示文件的前十行")])])]),t._v(" "),a("div",{staticClass:"language-shell extra-class"},[a("pre",{pre:!0,attrs:{class:"language-shell"}},[a("code",[a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 查看 file.txt 文件的前 10 行内容")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("head")]),t._v(" file.txt\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 查看 file.txt 文件的前 5 行内容")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("head")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[t._v("-n")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("5")]),t._v(" file.txt\n")])])]),a("h3",{attrs:{id:"tail命令-显示文件尾部的部分"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#tail命令-显示文件尾部的部分"}},[t._v("#")]),t._v(" "),a("code",[t._v("tail")]),t._v("命令:显示文件尾部的部分")]),t._v(" "),a("blockquote",[a("p",[t._v("基本语法:"),a("em",[t._v("tail 文件")])]),t._v(" "),a("blockquote",[a("p",[t._v("默认情况下 tail 显示文件的后十行")])])]),t._v(" "),a("div",{staticClass:"language-shell extra-class"},[a("pre",{pre:!0,attrs:{class:"language-shell"}},[a("code",[a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 查看 file.txt 文件的后 10 行内容")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("tail")]),t._v(" file.txt\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 查看 file.txt 文件的后 5 行内容")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("tail")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[t._v("-n")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("5")]),t._v(" file.txt\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 查看 file.txt 文件的后 10 行内容,并实时追踪文件更新")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("tail")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[t._v("-f")]),t._v(" file.txt \n")])])]),a("h3",{attrs:{id:"ln命令-在文件间建立链接"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#ln命令-在文件间建立链接"}},[t._v("#")]),t._v(" "),a("code",[t._v("ln命令")]),t._v(":在文件间建立链接")]),t._v(" "),a("blockquote",[a("p",[t._v("基本语法:"),a("em",[t._v("ln [选项] 源文件 目录文件或目录")])]),t._v(" "),a("blockquote",[a("p",[t._v("选项说明:")]),t._v(" "),a("p",[a("code",[t._v("-b")]),t._v("为删除的文件建立备份")]),t._v(" "),a("p",[a("code",[t._v("-d")]),t._v("允许root用户建立硬链接")]),t._v(" "),a("p",[a("code",[t._v("-F")]),t._v("与b相同")]),t._v(" "),a("p",[a("code",[t._v("-f")]),t._v("强行删除目标文件")]),t._v(" "),a("p",[a("code",[t._v("-i")]),t._v("在删除文件时给出提示")]),t._v(" "),a("p",[a("code",[t._v("-n")]),t._v("当目标文件是目录的符号链接时,替代该符号链接")]),t._v(" "),a("p",[a("code",[t._v("-s")]),t._v("用符号链接代替硬链接(建立符号链接)")]),t._v(" "),a("p",[a("code",[t._v("-v")]),t._v("输出被链接文件的文件名")]),t._v(" "),a("blockquote",[a("p",[t._v("软链接也称符号链接,类似 Windows 中的快捷方式")]),t._v(" "),a("p",[t._v("主要存放了链接其他文件的路径,删除软连接的方式与删除文件相同")])])])]),t._v(" "),a("div",{staticClass:"language-shell extra-class"},[a("pre",{pre:!0,attrs:{class:"language-shell"}},[a("code",[a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 创建一个软连接 myroot,连接到 /root 目录")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("ln")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[t._v("-s")]),t._v(" /root /myroot\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 删除软连接 myroot")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("rm")]),t._v(" /myroot\n")])])]),a("h3",{attrs:{id:"chmod命令-修改文件权限"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#chmod命令-修改文件权限"}},[t._v("#")]),t._v(" "),a("code",[t._v("chmod")]),t._v("命令:修改文件权限")]),t._v(" "),a("blockquote",[a("p",[t._v("基本语法:"),a("em",[t._v("chmod [选项] 文件或目录名")])]),t._v(" "),a("blockquote",[a("p",[t._v("选项说明:")]),t._v(" "),a("p",[a("code",[t._v("u")]),t._v(" 文件所有者")]),t._v(" "),a("p",[a("code",[t._v("g")]),t._v(" 文件所属组")]),t._v(" "),a("p",[a("code",[t._v("o")]),t._v(" 其它用户")]),t._v(" "),a("p",[a("code",[t._v("a")]),t._v(" 所有用户")]),t._v(" "),a("p",[a("code",[t._v("+")]),t._v(" 增加权限")]),t._v(" "),a("p",[a("code",[t._v("-")]),t._v(" 取消权限")]),t._v(" "),a("p",[a("code",[t._v("=")]),t._v(" 赋给权限")]),t._v(" "),a("p",[a("code",[t._v("r")]),t._v(" 读权限")]),t._v(" "),a("p",[a("code",[t._v("w")]),t._v(" 写权限")]),t._v(" "),a("p",[a("code",[t._v("x")]),t._v(" 执行权限")])])]),t._v(" "),a("div",{staticClass:"language-shell extra-class"},[a("pre",{pre:!0,attrs:{class:"language-shell"}},[a("code",[a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 将 file1.txt 文件设为所有人皆可读写")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("chmod")]),t._v(" a+rw file1\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 将 file.py 设定为只有该档案拥有者可以执行")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("chmod")]),t._v(" u+x file.py \n")])])]),a("h3",{attrs:{id:"gcc命令-编译"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#gcc命令-编译"}},[t._v("#")]),t._v(" "),a("code",[t._v("gcc")]),t._v("命令:编译")]),t._v(" "),a("blockquote",[a("p",[t._v("基本语法:"),a("em",[t._v("gcc [选项] 文件名")])]),t._v(" "),a("blockquote",[a("p",[t._v("常用选项:")]),t._v(" "),a("p",[a("code",[t._v("-v")]),t._v(" 查看gcc编译器的版本,显示gcc执行时的详细过程")]),t._v(" "),a("p",[a("code",[t._v("-o")]),t._v(" 指定输出文件名为file,这个名称不能跟源文件名同名")]),t._v(" "),a("p",[a("code",[t._v("-E")]),t._v(" 只预处理,不会编译、汇编、链接")]),t._v(" "),a("p",[a("code",[t._v("-S")]),t._v(" 只编译,不会汇编、链接")]),t._v(" "),a("p",[a("code",[t._v("-c")]),t._v(" 编译和汇编,不会链接")])])]),t._v(" "),a("div",{staticClass:"language-shell extra-class"},[a("pre",{pre:!0,attrs:{class:"language-shell"}},[a("code",[a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 编译 hello.c 并指定输出文件为 hello")]),t._v("\ngcc hello.c "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[t._v("-o")]),t._v(" hello\n")])])]),a("h2",{attrs:{id:"搜索查找类命令"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#搜索查找类命令"}},[t._v("#")]),t._v(" 搜索查找类命令")]),t._v(" "),a("h3",{attrs:{id:"find命令-查找文件"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#find命令-查找文件"}},[t._v("#")]),t._v(" "),a("code",[t._v("find")]),t._v("命令:查找文件")]),t._v(" "),a("blockquote",[a("p",[t._v("基本语法:"),a("em",[t._v("find 范围 方式 文件")])])]),t._v(" "),a("div",{staticClass:"language-shell extra-class"},[a("pre",{pre:!0,attrs:{class:"language-shell"}},[a("code",[a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 根据文件名查找 home 下的 file.txt 文件")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("find")]),t._v(" /home "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[t._v("-name")]),t._v(" file.txt\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 根据用户查找 home 下用户昵称为 DrangonOS 的文件")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("find")]),t._v(" /home "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[t._v("-user")]),t._v(" DrangonOS\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 根据文件大小查找系统中大小为 200M 的文件")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("find")]),t._v(" / "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[t._v("-size")]),t._v(" 200M\n")])])]),a("h3",{attrs:{id:"locate命令-定位文件路径"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#locate命令-定位文件路径"}},[t._v("#")]),t._v(" "),a("code",[t._v("locate")]),t._v("命令:定位文件路径")]),t._v(" "),a("blockquote",[a("p",[t._v("基本语法:"),a("em",[t._v("locate 文件")])]),t._v(" "),a("blockquote",[a("p",[t._v("locate 指令可以快速定位文件路径,利用事先建立的系统中所有文件名称及路径的 locate 数据库实现快速定位文件,无需遍历整个文件系统")]),t._v(" "),a("p",[t._v("但为了保证查询准确度,管理员须定期更新locate时刻")])])]),t._v(" "),a("div",{staticClass:"language-shell extra-class"},[a("pre",{pre:!0,attrs:{class:"language-shell"}},[a("code",[a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 创建 locate 数据库,第一次使用 locate指令前必须先创建数据库")]),t._v("\nupdatedb\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 定位 file.txt 文件的路径")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("locate")]),t._v(" file.txt\n")])])]),a("h3",{attrs:{id:"which命令-定位指令路径"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#which命令-定位指令路径"}},[t._v("#")]),t._v(" "),a("code",[t._v("which")]),t._v("命令:定位指令路径")]),t._v(" "),a("blockquote",[a("p",[t._v("基本语法:"),a("em",[t._v("which 指令")])])]),t._v(" "),a("div",{staticClass:"language-shell extra-class"},[a("pre",{pre:!0,attrs:{class:"language-shell"}},[a("code",[a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 检索 cp 指令所在路径")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("which")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("cp")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 输出")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token builtin class-name"}},[t._v("alias")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token assign-left variable"}},[t._v("cp")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v("'cp -i'")]),t._v("\n /usr/bin/cp\n")])])]),a("h3",{attrs:{id:"grep命令-过滤查找-搜索字符串"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#grep命令-过滤查找-搜索字符串"}},[t._v("#")]),t._v(" "),a("code",[t._v("grep")]),t._v("命令:过滤查找(搜索字符串)")]),t._v(" "),a("blockquote",[a("p",[t._v("基本语法:"),a("em",[t._v("grep 查找内容 源文件")])]),t._v(" "),a("blockquote",[a("p",[t._v("grep 命令可以搜索特定字符串来并显示出来,一般用来过滤先前得结果,避免显示太多不必要得信息")])])]),t._v(" "),a("div",{staticClass:"language-shell extra-class"},[a("pre",{pre:!0,attrs:{class:"language-shell"}},[a("code",[a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 查找 hello.txt 文件中 “yes” 所在行")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("grep")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"yes"')]),t._v(" hello.txt\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 查找 hello.txt 文件中 “yes” 所在行")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("cat")]),t._v(" hello.txt "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("grep")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"yes"')]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 查找 hello.txt 文件中 “yes” 所在行并显示行号")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("cat")]),t._v(" hello.txt "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("grep")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[t._v("-n")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"yes"')]),t._v("\n")])])]),a("blockquote",[a("blockquote",[a("blockquote",[a("p",[a("code",[t._v("|")]),t._v("管道命令:将某命令的结果输出给另一命令")])])])]),t._v(" "),a("h2",{attrs:{id:"压缩解压类命令"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#压缩解压类命令"}},[t._v("#")]),t._v(" 压缩解压类命令")]),t._v(" "),a("h3",{attrs:{id:"tar命令-打包文件"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#tar命令-打包文件"}},[t._v("#")]),t._v(" "),a("code",[t._v("tar")]),t._v("命令:打包文件")]),t._v(" "),a("blockquote",[a("p",[t._v("基本语法:"),a("em",[t._v("tar [选项] 内容")])]),t._v(" "),a("blockquote",[a("p",[t._v("选项说明:")]),t._v(" "),a("p",[a("code",[t._v("-c")]),t._v("创建一个新的tar文件")]),t._v(" "),a("p",[a("code",[t._v("-v")]),t._v("显示运作过程信息")]),t._v(" "),a("p",[a("code",[t._v("-f")]),t._v("指定文件名称")]),t._v(" "),a("p",[a("code",[t._v("-z")]),t._v("调用gzip压缩命令执行压缩;")]),t._v(" "),a("p",[a("code",[t._v("-j")]),t._v("调用bzip2压缩命令执行压缩")]),t._v(" "),a("p",[a("code",[t._v("-t")]),t._v("查看压缩文件内容")]),t._v(" "),a("p",[a("code",[t._v("-x")]),t._v("解开tar文件")])])]),t._v(" "),a("div",{staticClass:"language-shell extra-class"},[a("pre",{pre:!0,attrs:{class:"language-shell"}},[a("code",[a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 将 file.tar.gz 解压到当前目录")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("tar")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[t._v("-zxvf")]),t._v(" a.tar.gz\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 将 /home 下的文件夹压缩为 file.tar.gz")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("tar")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[t._v("-zcvf")]),t._v(" file.tar.gz /home/\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 将 file.tar.gz 解压到 /tmp 目录下")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("tar")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[t._v("-zxvf")]),t._v(" file.tar.gz "),a("span",{pre:!0,attrs:{class:"token parameter variable"}},[t._v("-c")]),t._v(" /tmp\n")])])]),a("blockquote",[a("blockquote",[a("blockquote",[a("p",[t._v("tar 打包后的文件为 .tar.gz 文件")])])])]),t._v(" "),a("h3",{attrs:{id:"gzip命令-压缩和解压缩文件"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#gzip命令-压缩和解压缩文件"}},[t._v("#")]),t._v(" "),a("code",[t._v("gzip")]),t._v("命令:压缩和解压缩文件")]),t._v(" "),a("blockquote",[a("p",[t._v("基本语法:"),a("em",[t._v("gzip [选项] 文件")])]),t._v(" "),a("blockquote",[a("p",[t._v("选项说明:")]),t._v(" "),a("p",[a("code",[t._v("-c")]),t._v("将输出写到标准输出上,并保留原有文件。")]),t._v(" "),a("p",[a("code",[t._v("-d")]),t._v("将压缩文件解压。")]),t._v(" "),a("p",[a("code",[t._v("-l")]),t._v("对每个压缩文件,显示下列字段:压缩文件的大小、未压缩文件的大小、压缩比、未压缩文件的名字")]),t._v(" "),a("p",[a("code",[t._v("-r")]),t._v("递归式地查找指定目录并压缩其中的所有文件或者是解压缩。")]),t._v(" "),a("p",[a("code",[t._v("-t")]),t._v("测试,检查压缩文件是否完整。")]),t._v(" "),a("p",[a("code",[t._v("-v")]),t._v("对每一个压缩和解压的文件,显示文件名和压缩比。")]),t._v(" "),a("p",[a("code",[t._v("-num")]),t._v("用指定的数字num调整压缩的速度,-1或--fast表示最快压缩方法(低压缩比),-9或--best表示最慢压缩方法(高压缩比),系统缺省值为6")])])]),t._v(" "),a("div",{staticClass:"language-shell extra-class"},[a("pre",{pre:!0,attrs:{class:"language-shell"}},[a("code",[a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 将usr.tar压缩为usr.tar.gz文件")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("gzip")]),t._v(" usr.tar\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# file1.txt压缩为file1.txt.gz文件")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("gzip")]),t._v(" file1.txt\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 将压缩文件usr.tar解压,并列出详细的信息")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("gzip")]),t._v(" –dv usr.tar.gz\n")])])]),a("h3",{attrs:{id:"unzip命令-压缩和解压缩文件-zip拓展"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#unzip命令-压缩和解压缩文件-zip拓展"}},[t._v("#")]),t._v(" "),a("code",[t._v("unzip")]),t._v("命令:压缩和解压缩文件(zip拓展)")]),t._v(" "),a("blockquote",[a("p",[t._v("基本语法:"),a("em",[t._v("unzip [选项] 文件名.zip")])]),t._v(" "),a("blockquote",[a("p",[t._v("选项说明:")]),t._v(" "),a("p",[a("code",[t._v("-x")]),t._v("文件列表 解压缩文件,但不包括指定的file文件。")]),t._v(" "),a("p",[a("code",[t._v("-v")]),t._v("查看压缩文件目录,但不解压。")]),t._v(" "),a("p",[a("code",[t._v("-t")]),t._v("测试文件有无损坏,但不解压。")]),t._v(" "),a("p",[a("code",[t._v("-d")]),t._v("目录 把压缩文件解到指定目录下。")]),t._v(" "),a("p",[a("code",[t._v("-z")]),t._v("只显示压缩文件的注解。")]),t._v(" "),a("p",[a("code",[t._v("-n")]),t._v("不覆盖已经存在的文件。")]),t._v(" "),a("p",[a("code",[t._v("-o")]),t._v("覆盖已存在的文件且不要求用户确认。")]),t._v(" "),a("p",[a("code",[t._v("-j")]),t._v("不重建文档的目录结构,把所有文件解压到同一目录下")])])]),t._v(" "),a("div",{staticClass:"language-shell extra-class"},[a("pre",{pre:!0,attrs:{class:"language-shell"}},[a("code",[a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 将压缩文件text.zip在当前目录下解压缩")]),t._v("\nuzip text.zip\n")])])]),a("h2",{attrs:{id:"编辑命令vi"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#编辑命令vi"}},[t._v("#")]),t._v(" 编辑命令vi")]),t._v(" "),a("h3",{attrs:{id:"vi编辑器介绍"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#vi编辑器介绍"}},[t._v("#")]),t._v(" vi编辑器介绍")]),t._v(" "),a("p",[t._v("vi 编辑器是 Linux 系统下的标准编辑器,vi 可以分为三种状态,分别是命令行模式、插入模式和底行模式,各模式的功能区分如下:")]),t._v(" "),a("ul",[a("li",[t._v("命令行模式:控制屏幕光标的移动,字符、字或行的删除,移动复制某区段及进入插入模式下,或者到底行模式")]),t._v(" "),a("li",[t._v("插入模式:只有在插入模式下,才可以做文字输入,按 ESC 键可回到命令行模式")]),t._v(" "),a("li",[t._v("底行模式:将文件保存或退出 vi ,也可以设置编辑环境,如寻找字符串、列出行号等")])]),t._v(" "),a("p",[t._v("在使用时通常把 vi 简化成两个模式,将底行模式也算入命令行模式")]),t._v(" "),a("h3",{attrs:{id:"命令模式-command-mode"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#命令模式-command-mode"}},[t._v("#")]),t._v(" 命令模式(Command mode)")]),t._v(" "),a("p",[t._v("启动 vi ,在系统提示符号输入 vi 及文件名称后,就进入 vi 全屏幕编辑画面,处于命令行模式,可移动光标、删除、移动、复制")]),t._v(" "),a("blockquote",[a("p",[a("code",[t._v("i")]),t._v("当前光标前插入")]),t._v(" "),a("p",[a("code",[t._v("a")]),t._v("当前光标后插入")]),t._v(" "),a("p",[a("code",[t._v("o")]),t._v("当前光标所在行下插入空行")]),t._v(" "),a("p",[a("code",[t._v("I")]),t._v("当前光标所在行上插入空行")]),t._v(" "),a("p",[a("code",[t._v("A")]),t._v("插于行首")]),t._v(" "),a("p",[a("code",[t._v("O")]),t._v("插于行尾")]),t._v(" "),a("p",[a("code",[t._v("x")]),t._v("删除一个字符")]),t._v(" "),a("p",[a("code",[t._v("dd")]),t._v("删除光标所在的行")])]),t._v(" "),a("h3",{attrs:{id:"插入模式-insert-mode"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#插入模式-insert-mode"}},[t._v("#")]),t._v(" 插入模式(Insert mode)")]),t._v(" "),a("p",[t._v("切换到插入模式才能够输入文字,在命令行模式下按下字母 i 进入插入模式,进行字符的输入和文件的编辑")]),t._v(" "),a("blockquote",[a("p",[t._v("按"),a("code",[t._v("ESC")]),t._v("返回命令模式")]),t._v(" "),a("p",[t._v("按"),a("code",[t._v("ESC")]),t._v("后输入“:”,进入底行模式")])]),t._v(" "),a("h3",{attrs:{id:"底行模式-lastline-mode"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#底行模式-lastline-mode"}},[t._v("#")]),t._v(" 底行模式(Lastline mode)")]),t._v(" "),a("p",[t._v("在命令行模式下,按一下冒号 :键进入底行模式")]),t._v(" "),a("blockquote",[a("p",[a("code",[t._v(": w 文件名")]),t._v(" 将文件以指定文件名保存")]),t._v(" "),a("p",[a("code",[t._v(": wq")]),t._v(" 输入wq,存盘并退出vi")]),t._v(" "),a("p",[a("code",[t._v(": q!")]),t._v(" 输入q!,不存盘强制退出vi")])])])}),[],!1,null,null,null);a.default=v.exports}}]);